简体   繁体   English

REST API测试:HTTP Post使用Frisby.js返回500

[英]REST API Testing: HTTP Post returns 500 with Frisby.js

I am using Frisby.js to submit a POST request with JSON data and test the JSON response. 我正在使用Frisby.js提交带有JSON数据的POST请求并测试JSON响应。 However, my query returns HTTP Status 500. The same POST request works fine in CURL in my command line, as well as Postman. 但是,我的查询返回HTTP状态500.相同的POST请求在我的命令行中的CURL以及Postman中正常工作。 What could be the problem? 可能是什么问题呢?

CURL request: curl -H "Content-Type: application/json; charset=UTF-8" -X POST -d " json_data " url CURL请求: curl -H“Content-Type:application / json; charset = UTF-8”-X POST -d“ json_dataurl

FRISBY test: FRISBY测试:

frisby
.create("Submit request")
.post(url, json_data, {"json": true, "content-type": "application/json;charset=UTF-8"})
.expectStatus(200)
.inspectBody()
.toss();

OUTPUT with Frisby: 与Frisby一起输出:

Destination URL may be down or URL is invalid, Error: ETIMEDOUT F 目标网址可能已关闭或网址无效,错误:ETIMEDOUT F.

Failures: 失败:

1) Frisby Test: Submit request [ POST url ] 1)Frisby测试:提交请求[POST url ]

Message: Expected 500 to equal 200. 消息:预计500到200等于。

Stacktrace: 堆栈跟踪:

 Error: Expected 500 to equal 200.
at null.<anonymous> 
at null.<anonymous> 
at Timer.listOnTimeout (timers.js:92:15)

Finished in 5.032 seconds 1 test, 1 assertion, 1 failure, 0 skipped 完成5.032秒1次测试,1次断言,1次失败,0次跳过

The 500 error and accompanying message that results "Destination URL..." is from Frisby itself , not your server. 导致“目标网址...”的500错误和附带消息来自Frisby本身 ,而不是您的服务器。 Frisby adds the error if the connection times out. 如果连接超时,Frisby会添加错误。 Try increasing it to 10 seconds. 尝试将其增加到10秒。

...

.get(url)
.timeout(10000)

...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM