I have a body requests, 500+, which I need to pass through an API and save a result. How do I pass that many request and save request and response?
Note: All those body requests are located on my desktop under folder called “Data”.
Also, not all requests have similar length, they can very but structure is same, defined below. If it helps, I don’t need to modify any data within my data set, I am just looking for a way to submit it through API.
There’s no direct way to pass the body to a request inside Postman.
I can think of one way to get this thing working:
Write a script (probaby a nodeJS script or any scripting language you’re comfortable with) to move all the request bodies from all the files into one file as an array of JSON, this file can be directly used inside the collection-runner in Postman to run each request body for a given endpoint.
// The data to be written to file
let dataToFile = {
requestName: `${request.name || request.url}-${pm.info.iteration}`, // Add this
fileExtension: 'json',
responseData: pm.response.text()
};
I know this is a bit complex, but this is all I can think of right now.
Maybe other people in the community have a better solution to it!