我使用 Frisby 框架编写 API 测试用例。当我将 url 和凭据放入邮递员或 DHC 时,响应正确,但在 frisby 测试用例中我收到错误:-
代码如下: -
var frisby = require('frisby');
frisby.create('User Authentication')
//send the params to below url
.post("url",
{ username: "username",
password: "password"
},
{ json: true,
headers: {Accept:'application/json',
'Accept-Encoding':'Encoding:gzip, deflate',
'Accept-Language':'en-US,en;q=0.8',
Connection:'keep-alive',
'Content-Length':'107',
'Content-Type':'application/json',
Host:'url.com',
Origin:'http://url.com',
Referer:'http://url.com/',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'X-Application-Key':'1234545',
'X-Requested-With':'XMLHttpRequest'
}
}
)
.expectStatus(200)
.toss();