2

I'm using Postman automate an API with Newman.But the response body of the API call is not showing in the newman.

var body = JSON.parse(responseBody);
tests["Response Body ", body] = true;

I have tried the above code,but even after successful API call the response is not printing in the "Test results" tab.

the output of above is showing as,

PASS [object Object]

Any suggestions to print the API response will be of great help.

Thanks in advance!

Linu
  • 589
  • 1
  • 10
  • 23

1 Answers1

4

I assume you're using the cli reporter with Newman, you could just add a console.log(pm.response.json()) statement to the Tests tab.

That should print out the response body on the console during the Newman run.

If you wanted something to show you all the details of the Newman run in a separate report, you could also use a different reporter, like this HTML one ;)

https://www.npmjs.com/package/newman-reporter-htmlextra

Danny Dainton
  • 23,069
  • 6
  • 67
  • 80
  • Thanks a lot for the swift response! I have tried "console.log(pm.response.json())" but it doesn't show anything.Is there any other way to print the response in the "test results" tab or am i doing anything wrong.Can you please guide. – Linu Aug 11 '19 at 19:01