postman runner save response for each iteration
Asked Answered
E

1

1

I am running the postman runner for a GET request, that uses a data file to iterate through values for a query parameter, such as a user's email. I'd like to store the response for each iteration in a single JSON or data file to match the responses to each email iteration.

Could someone help with how I might approach this?

Eastlake answered 5/1, 2022 at 13:25 Comment(3)
Welcome to So, Please take a look at this to ask a better question. please share some research or code you tested beforeJulianjuliana
Answered here: https://mcmap.net/q/489176/-bulk-post-put-api-requests-using-postman-or-any-other-means | Regarding matching, you don't have to save responses, see learning.postman.com/docs/writing-scripts/test-scriptsWinshell
Does this answer your question? Bulk POST/PUT API requests using POSTMAN or any other meansMattox
W
0

A simple solution to get the Postman runner responses in a single JSON/CSV format:

  1. Create a collection and add the APIs to the collection.
  2. In the 'Tests' tab, add a JavaScript script to store the API response with specific values into environment variables. enter image description here

let responses = pm.collectionVariables.get('collectionResponses');
if(responses) {
  responses = JSON.parse(responses);
} else {
  responses = [];
}

responses.push({link : pm.response.json().poster,Id:pm.response.json().id});
pm.collectionVariables.set('collectionResponses', JSON.stringify(responses));


console.log(JSON.stringify(responses));

The above code will save the reponse into 'collectionResponses' variable.

  1. Run the runner with the APIs.
  2. After completion, go to the collection, right-click, and select 'Edit.'
  3. Navigate to the 'Variables' tab and read the variable values.
  4. If you need the data in CSV format, copy the JSON responses and use an online tool to convert them to CSV.
Whosoever answered 26/7, 2023 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.