Outputting responses from api requests in a test

Hi, I have a collection of requests that I have grouped together to run in one go.
What I’m trying to figure out if there is a way of outputting the response detail in the body for all of them?
I’m not looking to assert that they are correct (yet) I’d just like to see what they all output initially.
Many thanks.

Hi @agoodall, if you want to simply inspect the response, you can run the collection in the runner and then follow these steps.

  1. Click on the console at the bottom left-hand side.
  2. You will be able to see all the request made. Expand on of them
  3. Now expand the Response body. This is the response of the made request.

Inspect all the responses following the above steps.

Thanks.

That’s great.
Is there anyway of outputting this so that I don’t have to expand each response in turn?

Yes, @agoodall . There are multiple ways to do such a thing.

  1. Store it in a global variable and console log the variable value at the very last request
  2. console.log(response.body) at every request.

Thanks.

In addition to what @gunjan.bhowmick suggested, you can use newman to export the response to a file as suggested here.

Here are more details on the newman reporter: GitHub - postmanlabs/newman: Newman is a command-line collection runner for Postman

2 Likes

using the later solution for each request I get a
There was an error in evaluating the test script: ReferenceError: response is not defined.
I’m guessing that the repsonse.body needs defining (const or var?) for it to be picked up?