# Saving response body data from newman run

**URL:** <https://community.postman.com/t/saving-response-body-data-from-newman-run/68389>\
**Category:** Help Hub\
**Tags:** newman-reports\
**Created:** [September 13, 2024, 4:09pm UTC](https://community.postman.com/t/saving-response-body-data-from-newman-run/68389 "2024-09-13T16:09:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpjpjp](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jpjpjp](https://community.postman.com/u/jpjpjp)\
**Post date:** [September 13, 2024, 4:09pm UTC](https://community.postman.com/t/saving-response-body-data-from-newman-run/68389/1 "2024-09-13T16:09:01Z")

</div>

I’m trying to save the response bodies from a newman run.

I tried running the json reporter as described in [this thread](https://community.postman.com/t/save-body-results-to-a-csv-or-json-file-using-newman/5861/2).

In the outputted json the response data is being represented as a stream, ie"

```json
        "response": {
          "id": "730f7ce4-810a-46f7-a935-fae33df61cb3",
          "status": "OK",
          "code": 200,
          "header": [...],
          "stream": {
            "type": "Buffer",
            "data": [123, 34 ... lots and lots of numbers]
            ]
          },
          "cookie": [],
          "responseTime": 17,
          "responseSize": 178
        },

```

Is there a configuration that I need to set to get the response data as a json object instead?

The server I’m making the request to is returning the “Content Type” header to “application/json; charset=utf-8”. Is there anything that could change on the server side that would help me get the desired output from the json reporter?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 18, 2024, 4:06pm UTC](https://community.postman.com/t/saving-response-body-data-from-newman-run/68389/2 "2024-09-18T16:06:10Z")

</div>

Hey @jpjpjp 👋

You could use this method to save the responses - might not be 100% to you context but if could work for you.

> [@Save body results to a CSV or JSON file - using newman](https://community.postman.com/t/save-body-results-to-a-csv-or-json-file-using-newman/5861/17):
>
> Hey @hdabas, Welcome to the community! rocket Just jumping in here to see if I can help with getting the request name from the Newman run. Newman has certain events that can be access with the .on() function - A full list can be found here: A basic example of getting the name of the Request would be using something like this: const newman = require('newman') newman.run({ collection: '\<Postman Echo Collection\>', }).on('request', (err, args) =\> { console.log(args.item.name) }) Here’…

---

<div class="post-metadata">

**Author:** ![jpjpjp](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jpjpjp](https://community.postman.com/u/jpjpjp)\
**Post date:** [September 18, 2024, 6:31pm UTC](https://community.postman.com/t/saving-response-body-data-from-newman-run/68389/3 "2024-09-18T18:31:57Z")

</div>

Thanks Danny. The idea in this thread to use a post request script to write the response data out to a file is something I could probably do, although correlating the correct file to a test failure in the newman output would take some thinking about.

Before going down that path, I just wanted to close the loop on the original question. Can anyone confirm that there IS NOT a way to get the response body in JSON format as part of the output from the JSON reporter?

I’m very curious why the JSON reporter output provides a long list of numbers for the “data” element in the response. Is this valuable to anyone? I’d love to hear how this could be interpreted or translated back to a usable format.

Cheers.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 18, 2024, 6:49pm UTC](https://community.postman.com/t/saving-response-body-data-from-newman-run/68389/4 "2024-09-18T18:49:58Z")

</div>

The link is showing you how to do this using Newman as a library and creating a script. It’s not doing anything via a post response script.

I don’t know what that JSON reporter should be out putting, I’ve never used it.

You could also use the Newman CSV reporter to write the response body to a file.

> **[newman-reporter-csv](https://www.npmjs.com/package/newman-reporter-csv)**
>
> A CSV reporter for Newman.. Latest version: 1.3.0, last published: 2 years ago. Start using newman-reporter-csv in your project by running \`npm i newman-reporter-csv\`. There are 3 other projects in the npm registry using newman-reporter-csv.

```auto
newman run postman_collection.json -e postman_environment.json -r csv --reporter-csv-includeBody

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [October 18, 2024, 6:50pm UTC](https://community.postman.com/t/saving-response-body-data-from-newman-run/68389/5 "2024-10-18T18:50:07Z")

</div>

Closed on October 18, 2024, 6:50pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
