Ad

Multiple PUT Requests Via Postman?

- 1 answer

We had an issue with our Shopify store where we lost all our product images somehow. Well, the images are still in their cloud, but have become disassociated from the products themselves.

Long story short, the images could not be reassociated by Shopify support, so I created a bunch (thousands) of PUT requests to update the products with the appropriate product images.

I am using Postman, but from what I can tell, there's not a quick way to send the PUT commands, headers and JSON string all at once to make the update for each of the several thousand images.

My formatted strings are as such:

Request:

PUT [store name]/admin/api/2019-04/products/[product id].json

Headers:

Host: [store url] Content-Type: application/json Authorization: Basic [api key] cache-control: no-cache

JSON:

{'product': {'id': [the id],'images': [{'src': '[image url already in shopify]'}]}}

Is there a way in Postman to run all these calls at once, or if not through Postman, some other program? We don't have cURL here at my work so installing that is not an option.

I did see there are bulk edit commands in Postman, but it appears I'd have to enter each part manually, so for thousands of calls, this isn't a viable option. I have a feeling the answer is I'd have to write an app to do this, which I can do, but since I have all these formatted strings already I thought there might be a way to make use of what I have now.

Ad

Answer

Assuming that you do have the data in a CSV file you could use Postman's Collection Runner with a data file and data variables. Here's a blog post that explains it pretty well:

https://blog.getpostman.com/2018/04/11/looping-through-a-data-file-in-the-postman-collection-runner/

Ad
source: stackoverflow.com
Ad