38

How can I save API response, that I get in Postman, to a Json file or CSV file?

Ashu Srivastava
  • 401
  • 1
  • 4
  • 3

5 Answers5

60

There are 2 ways of saving the response to a file:

  1. Click on the small down arrow besides the "Send" button, this will show the "Send and Download" button. Click on it and postman will ask you where to save the response, when the request is done.

send and download button

  1. There is a "Download" button in the response section of the window.

download button

franksands
  • 1,748
  • 16
  • 21
  • In case you want to save it to the same collection, you can use the 'Save Response' feature. That will make it available under the 'Examples (0)' button on top right. – Gaurav Ojha Dec 05 '18 at 05:51
  • 1
    Why did I never seen this button before now... I actually wrote a postman script just for this.... LOL... – Kimmo Hintikka Jan 04 '19 at 13:01
7

In Postman 7.3 simply click Save Response after executing a request.

enter image description here

CoolMind
  • 26,736
  • 15
  • 188
  • 224
4

At the right top corner of postman, you can see Examples(0) drop down. Tapping that will make this request and response to be saved as a example for future reference.

enter image description here

You can see I have saved a response as a example. That's all. This will be helpful for those who want to save the response in postman itself other than like downloading like a json or csv as mentioned in the question.

Swathi
  • 1,544
  • 1
  • 13
  • 9
  • 1
    Hi, any way to save responses as examples in the collection from the collection runner ? We want to save all responses to provide a reference for each regression test. Thx – Mario Nov 27 '20 at 13:17
4

I found a really checky solution for this since there is no supported way of automatically exporting the response (or when using newma cli). You can use JSON.Parse(responseBody); within the Tests console, and then write a test that is the response name.

reponseBodyData = JSON.parse(responseBody);

pm.test("Response Body Printout= (" + responseBody
 + ")", function () {
});

When using Newman, simply use the following:

newman run "<collection path>" -e "<environment path>" -d "<data file path>" -r "json"

The JSON now will contain the response body within it, and therefore can be parsed.

2

For Future Visitors:

You can visit this collection and use it: https://documenter.getpostman.com/view/3407886/RWgp1fB5

On sending a request, the response is saved to your file system via a local server. (Already included as a GitHub project along with instructions to use it in the collection project^)

You can send multiple requests or using the collection runner - you can run a collection or a folder. All responses will be saved after each request being sent out.

You can even store extra meta-data or maybe your test counts, variable names, variable values, URL, basically anything/everything.

Sivcan Singh
  • 1,775
  • 11
  • 15