Search code examples
postmanpostman-collection-runner

Print API response in "Test results" tab in Postman


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!


Solution

  • 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