Need to capture response body of each iteration

Hello All,
I am created and API request in Postman and i am iterating the same for 30 iterations with different values such as passing different username everytime.
Now i have kept certain test in test scripts.
now in result i want to save request/response created/ downloaded in each iteration .
do we have any solution for that.

basically i want to create a report like postman does when i execute test using runner.
but i am unable to export the exact report from generated by runner in HTML or some other format.

any suggestions will be really help me.
Thanks in anticipation

This collection might help you in writing the response data to a file:

You can take the idea from it on how you can use pm.sendRequest feature of postman and build upon the nodejs server code and the script to make your own reporter etc.

1 Like

@sivcan This is great. Very much appreciated. Is there a way to write results from multiple iterations? For instance, if I use collection runner to run a request 100 times, Iā€™m currently only getting one response and not all 100 written to the file.

@rpearcy Hi, this is because the name of the request is the same and thus, the new data is overriding the existing data in the same file.

What you can do is Right click the collection >Edit > Tests

And change the request name to the following:

requestName: `${request.name || request.url}-${pm.info.iteration}`,

Like so:

Now, for every iteration a new file will be stored along with the corresponding iteration that you ran via the runner.

1 Like

@sivcan Thanks for the response. I ended up doing something similar by adding Date.now() to the file name so it will give me a unique file name for each iteration.

Thanks again for this. Helped me quite a bit to accomplish some testing at work.

1 Like

@sivcan,

I am using the Collection runner and pulling the request body in from an external file. Any idea how I could pull the name of that external file into the name of the file created for the response body?

Turns out the name of the external file used to populate the request body cannot be grabbed. My workaround was to use a unique identifier in the request body (also had to scrub this string for invalid filename characters):

can i use to save dynamic itemid in Json response, instead of whole body ? with multiple iteration ?