简体   繁体   中英

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. However, my query returns HTTP Status 500. The same POST request works fine in CURL in my command line, as well as Postman. What could be the problem?

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

FRISBY test:

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

OUTPUT with Frisby:

Destination URL may be down or URL is invalid, Error: ETIMEDOUT F

Failures:

1) Frisby Test: Submit request [ POST url ]

Message: Expected 500 to equal 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

The 500 error and accompanying message that results "Destination URL..." is from Frisby itself , not your server. Frisby adds the error if the connection times out. Try increasing it to 10 seconds.

...

.get(url)
.timeout(10000)

...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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