testingpostmanexportconsole.logpostman-collection

Postman manipulate test data after requests


Sorry if my englidh it not great.

The context: I have a collection on Postman, where it run the first request, store some data, put as a enviormente variable and then run the second request with the storaged data of enviorment variables.

Now, i have on the test nav some cleaning working of the body reponse data i dont want to. On my test nav i have the result json/object already cleaned with the data i want.

For example, one of my requests return as body result this json:

{ "expand": "named", "startAt": 0, "maxResults": 100, "total": 1 }

Now, on my test results, simply have this.

const responseJson = pm.response.json(); delete reponseJson.expand

if i make a console.log it correctly detele expand and shows:

{ "startAt": 0, "maxResults": 100, "total": 1 }

Okey, so in my case, imagine that the parameter 'maxResults' its set as enviorment variable and make another request with the value of 100. All this works correctly.

Now my question its how i should continue manipulating this data. As i told there are two different request. What can i do if i want to have the data of the first request (already cleaned up on test nav) and the second request (also cleaned up on test nav). Because the only thing i can do with this already cleaned data it show it on the console.log

Any suggestion for some tool (for example a lib of npm or whatever) that could get the cleaned data (of the test nav) and export it, or execute postman collection with other data that could get the test nav cleaned data and store it or manipulate it

Thanks, if anyone knows anything i appreciate it. I would explain my self its necessary. Please help!!!!!


Solution

  • There's no simple way to export data with a test script. If you're highly motivated there are some high effort ways to technically do this: How to programmatically save the response to file in Postman

    You'll have to decide what is more effort, writing an app to do it for you, or compiling the data from your responses and saving them to an environment variable, then copy it to a file yourself.