Created
December 9, 2021 06:19
-
-
Save yongchengzhao/74aa59765cd16578cdebd732817820ce to your computer and use it in GitHub Desktop.
Postman pre-request request formdata(在 Postman 的 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
const authReq = { | |
url: "http://10.215.xxx.xxx:18200/sys-auth/oauth/token", | |
method: "POST", | |
header: { | |
"Authorization": "Basic ZmF3a2VzOmZhd2tlc19zZWNyxxx=" | |
}, | |
body: { | |
mode: "formdata", | |
formdata: [ | |
{key: "scope", value: "all"}, | |
{key: "grant_type", value: "password"}, | |
{key: "username", value: "xxx"}, | |
{key: "password", value: "f415bf878b0241c260ab2a5a3a24exxx"} | |
] | |
} | |
} | |
pm.sendRequest(authReq, (error, res) => { | |
// console.log(error ? error: res.json()); | |
var access_token = res.json()["access_token"]; | |
// console.log(access_token); | |
pm.request.headers.add({ | |
key: "Fawkes-Auth", | |
value: access_token | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment