邮差:纽曼收集运动员无法通过呼叫在体内发送表格url编码的参数

时间:2017-07-08 08:01:29

标签: postman

在邮递员中发送凭据以在主体部分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"}

另外,当我从邮递员生成卷曲代码时,我没有看到附加的用户/ 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 个答案:

答案 0 :(得分:1)

所以这里的问题是安装了Newman的版本。 所以我得到了最新版本:

//to install
npm install -g newman

//needed to use Newman.run instead of Newman.execute
newman run c:\s -e c:\env --reporters cli,json --reporter-json-export c:\out.json -k

//-k was required to bypass ssl security issues.