# Outputting responses from api requests in a test

**URL:** <https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881>\
**Category:** Help Hub\
**Tags:** tests, collections\
**Created:** [January 6, 2021, 7:27am UTC](https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881 "2021-01-06T07:27:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![agoodall](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@agoodall](https://community.postman.com/u/agoodall)\
**Post date:** [January 6, 2021, 7:27am UTC](https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881/1 "2021-01-06T07:27:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gunjandb](https://avatars.discourse-cdn.com/v4/letter/g/ac8455/32.png) [@gunjandb](https://community.postman.com/u/gunjandb)\
**Post date:** [January 6, 2021, 9:59am UTC](https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881/2 "2021-01-06T09:59:20Z")

</div>

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.  
 ![Screenshot 2021-01-06 at 3.17.03 PM](https://us1.discourse-cdn.com/getpostman/original/3X/a/6/a6e9eeee982ffe7264a134ffac4fc4f080668135.png)
2. You will be able to see all the request made. Expand on of them  
 ![Screenshot 2021-01-06 at 3.19.20 PM](https://us1.discourse-cdn.com/getpostman/original/3X/4/5/4598ae61761148ce49ed0df595d12308e8f885a2.png)
3. Now expand the Response body. This is the response of the made request.  
 ![Screenshot 2021-01-06 at 3.22.58 PM](https://us1.discourse-cdn.com/getpostman/original/3X/2/8/288d474dabc1852a0519b4072bdd037c92622d0d.png)

Inspect all the responses following the above steps.

Thanks.

---

<div class="post-metadata">

**Author:** ![agoodall](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@agoodall](https://community.postman.com/u/agoodall)\
**Post date:** [January 6, 2021, 11:30am UTC](https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881/3 "2021-01-06T11:30:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gunjandb](https://avatars.discourse-cdn.com/v4/letter/g/ac8455/32.png) [@gunjandb](https://community.postman.com/u/gunjandb)\
**Post date:** [January 6, 2021, 11:49am UTC](https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881/4 "2021-01-06T11:49:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![taehoshino](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/taehoshino/32/6608_2.png) [@taehoshino](https://community.postman.com/u/taehoshino)\
**Post date:** [January 7, 2021, 2:36am UTC](https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881/5 "2021-01-07T02:36:50Z")

</div>

In addition to what @gunjandb suggested, you can use newman to export the response to a file as suggested [here](https://community.postman.com/t/save-body-results-to-a-csv-or-json-file-using-newman/5861/2).

Here are more details on the newman reporter: [GitHub - postmanlabs/newman: Newman is a command-line collection runner for Postman](https://github.com/postmanlabs/newman#reporters)

---

<div class="post-metadata">

**Author:** ![agoodall](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@agoodall](https://community.postman.com/u/agoodall)\
**Post date:** [January 8, 2021, 6:51pm UTC](https://community.postman.com/t/outputting-responses-from-api-requests-in-a-test/18881/6 "2021-01-08T18:51:28Z")

</div>

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?
