Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

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

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

TMartins
Visitor
1 0 0

Hello,

 

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, 

Tiago

TMartins_0-1604070374089.png

Reply 1 (1)

HunkyBill
Shopify Partner
4853 60 571

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! hunkybill@gmail.com http://www.resistorsoftware.com