Storing Multiple Values as Variables from the Response Body

Hi! I am trying to set up automation that retrieves certain values in a body and automatically updates them to variables for automation purposes. I have a call that retrieves a ton of information including scattered IPs, which I currently have to manually fill into variable slots to run a collection with each call per variable iteration. Is there a way to make this process automatic by having the variable fields automatically fill up with the specific IPs from the first call?

There are two general ways to create a loop if that is what you are after.

You can use sendRequest() in a Post response script to loop through your response. The advantage is that this doesn’t require the collection runner.

The other option is to create an array of the IP’s from the first request, then use setNextRequest() on the subsequent request to control the loop.

This has the advantages of being two separate requests in the GUI, and generally requires slightly less code.

If you can provide an example of the response for the first request and details on what information is needed for the second request, then I’m sure someone will be able to provide an example of how to create a loop using sendRequest() or setNextRequest().

You can also try searching the forums for these terms which should provide some examples.

How would I go about creating an array of the IPs as they are returned by the first request?

Using the Javascript filter function. You also have the Lodash library available in the Postman sandbox. If you provide an example response, then we can show you a working example.

Thank you so much, all of my issues have been remediated