Answers for "how to pass token in postman"

0

postman set token from response

// Add to collection pre scripts
// Also don’t forget to set auth in endpoint as {{access_token}}

let tokenUrl = 'Your url to get token';
let email = 'Your email';
let password = 'Your password';

if (pm.environment.name === 'Your env') {
    tokenUrl = 'Another env token url';
}

const getTokenRequest = {
  method: 'POST',
  url: tokenUrl,
  body: {
      mode: 'formdata',
      formdata: [
          { key: 'email', value: email },
          { key: 'password', value: password }
      ]
  }
};

pm.sendRequest(getTokenRequest, (err, response) => {
  const jsonResponse = response.json();
  const newAccessToken = jsonResponse.data.token;
  pm.variables.set('access_token', newAccessToken);
});
Posted by: Guest on June-16-2021
0

how to add client id and client secret in postman

[ Base URL: api-sandbox.dhl.com/dgff/transportation ]
Posted by: Guest on January-04-2021

Code answers related to "how to pass token in postman"

Browse Popular Code Answers by Language