在邮递员发送凭据设置登录身体部分 x-www-form-ulrencoded。这绝对没问题。
在 newman collection runner 中导出此脚本后,这不起作用。
以下是输出:
-------------------------------------------------------------------------------------------
401 3361ms Login Call [POST] https://<url>/login
------------------------------------------------------------
Request headers:
{
"content-type": "application/x-www-form-urlencoded",
"host": "<url>",
"accept-encoding": "gzip, deflate",
"content-length": 0
}
Request data:
{
"userid": "user",
"password": "pswd"
}
------------------------------------------------------------
Response headers:
{
"x-frame-options": "SAMEORIGIN",
"content-type": "application/json",
"x-content-type-options": "nosniff",
"date": "...",
"cache-control": "no-cache",
"content-length": "120",
"x-xss-protection": "1; mode=block",
"connection": "close",
"accept-ranges": "bytes"
}
Response body:
{"errorCode":"401","errorMessage":"Login failed, please check the credentials","errorDescription":"API Request Failure"}
此外,当我从邮递员生成卷曲代码时,我没有看到 user/pswd 标头附加:
curl -X POST \
https://<url>/login \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'postman-token: 5b04e538-498c-9e43-2be9-8523073260f9'
使用 Postman Chrome 应用:
Postman for Chrome
Version 5.0.2
win / x86-64
Chrome 59.0.3071.115
1 回答
所以这里的问题是 Newman 的安装版本。所以我得到了最新版本: