Saving response body data from newman run

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

I tried running the json reporter as described in this thread.

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

        "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!

Hey @jpjpjp :wave:

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

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.

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 run postman_collection.json -e postman_environment.json -r csv --reporter-csv-includeBody