4

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

A. Ganesh
  • 71
  • 1
  • 3
  • 3
    Solved this, I had to add timeout(30000) after the post() call in the promise chain. API's that take a while to respond need this to be added. This is not there in the documentation and I had to dig around some forums to find it. – A. Ganesh Nov 17 '15 at 22:59

1 Answers1

0

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)

...
mrded
  • 4,674
  • 2
  • 34
  • 36