Skip to content

Instantly share code, notes, and snippets.

@ponich
Created August 16, 2019 14:48
Show Gist options
  • Save ponich/6da7f1ca42d780a7829068dcf7f70a23 to your computer and use it in GitHub Desktop.
Save ponich/6da7f1ca42d780a7829068dcf7f70a23 to your computer and use it in GitHub Desktop.
Postman (update token pre-request)
let login = pm.variables.get("login");
let password = pm.variables.get("password");
pm.sendRequest({
url: pm.variables.get("baseUrl") + '/api/v1/Account/authorization',
method: 'POST',
header: {
"content-type": "application/json"
},
body: {
mode: 'raw',
raw: JSON.stringify({ username: login, password: password })
}
}, (err, res) => {
let token = res.json().data.token.replace('bearer ', '');
pm.environment.set("token", token);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment