Created
August 16, 2019 14:48
-
-
Save ponich/6da7f1ca42d780a7829068dcf7f70a23 to your computer and use it in GitHub Desktop.
Postman (update token pre-request)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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