Execute multiple times a put request via test & pre-request script

My question: I have a put request that supports updates on a single product in Shopify. I want to use the put request to update the stock of multiple products so I would need to call the PUT request multiple times.

I have created a collection with multiple api calls and in one of them I create an environment array with the products that need to be updated.

The environment array looks like this: [{“shopify_id”:6711230070958,“id”:“279482”,“stock”:“9”},{“shopify_id”:6711230070958,“id”:“279482”,“stock”:“2”}].

Only relevant is the shopify_id and the stock object.

I managed to update a single product by adding the values to the body. Settings raw and json.

“product”: {
“id”: 6711230070958,
“variants”: [
“inventory_quantity”: 9}

I’ve already tried: Multiple things such as looking at the documentation learning center and the postman example api: link in the environment scanner collection is an example. Can’t make it to work though. Every help is welcome. Also tried working with an counter environment variable. link

Also found an example where you need to create a datafile. I am wondering if it is possible to avoid this?

1 Like