Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yongchengzhao/74aa59765cd16578cdebd732817820ce to your computer and use it in GitHub Desktop.
Save yongchengzhao/74aa59765cd16578cdebd732817820ce to your computer and use it in GitHub Desktop.
Postman pre-request request formdata(在 Postman 的 pre-request 中发送表单请求)
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