REST API - 502 Error while creating Products (BAD GATEWAY)

New Member
1 0 0



While creating products via the REST API, after some requests, the API returns a 502 Bad Gateway error.


In the first instance, I thought it would be the request limit so I have implemented a way to send the products in batches of 50 and with a delay of 1 second between each request ...


Unfortunately, while creating the products, I still get the same error. 


Is there anyone who has experienced this in the past or would be able to help?


Many thanks in advance, 



Shopify Expert
4491 45 486

That one is super easy to fix. Shopify will throw a 502 anytime it is overloaded. So when your Exception Handler gets handed a 502, you can simply sleep for say 10 seconds, and then run a retry on your code. It will almost always work then. If you wanted to get fancy you could back off retries by some exponential, like Sidekiq does, like 20, 40, 80, 160 seconds ... till it works.

You can expect 502. It is not an unusual return code.

Custom Shopify Apps built just for you!