升级邮递员后,我的预请求脚本停止工作。我使用脚本来检索令牌,以用于后续请求中的身份验证。我使用邮递员7.27.1
作为错误,我收到HPE_INVALID_HEADER_TOKEN
标题详细信息
脚本如下:
pm.sendRequest({
url: pm.environment.get("login_url"),
method: 'POST',
header: {
'Accept':'application/json',
'Content-Type':'application/x-www-form-urlencoded'
},
body: {
mode: 'urlencoded',
urlencoded: [
{key: "grant_type", value: "password", disabled: false},
{key: "username", value: pm.environment.get("username"), disabled: false},
{key: "password", value: pm.environment.get("password"), disabled: false}
]
}
}, function (err, res) {
console.log("Login response: ");
console.log(err);
console.log(res.json());
pm.request.headers.add({
disabled: false,
key: 'Authorization',
name: 'Bearer token',
value: "Bearer "+ res.json().access_token
});
});
我正在竭尽全力找出标头有什么问题吗??有人知道吗?