Newman: GET API response is not displayed in newman output

Created on 14 Nov 2014  路  9Comments  路  Source: postmanlabs/newman

newman -c testcase.json -e environment.json -s command successfully executed the API specified in the testcase.json file, it returned 200 response code and time it took, but the API response was not displayed. Do I need to setup other parameters? Thanks.

Most helpful comment

There should be a CLI option for this, I think the most useful option would be print response body on test failure

All 9 comments

This is to be expected. The idea of newman is to supplement the Postman collection running on the commandline. If you want to see the output you should probably be using postman. If you expect the output to be a certain format, add a test in postman and then newman will execute that test against the response.

@awang2003 You can use console.log(...) In your tests to print specific info from the response. As mentioned, the whole response is not printed anywhere.

One reason it would be quite helpful to have some option to log the actual data returned is for debugging purposes. I am actually in a situation right now where my Postman collections are running quite well using collection runner but a few are failing for some strange reason in Newman. By making the output available, I would be able to more easily see the point of failure and figure out why it is happening.

What are the tests that are failing? Response headers / body?

@abhijitkane , Thanks for asking but I actually figured out what the issue was.

There should be a CLI option for this, I think the most useful option would be print response body on test failure

I was looking for a similar kind of thing from newman.

how can i print the response body on failure and success ?

You can print the response using console.log command. An example below to append your tests
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"var jsonData = pm.response.json();",
"console.log(jsonData)"
]
}
}
]

Could someone share entire steps to output API response in output file.

Was this page helpful?
0 / 5 - 0 ratings