What's your biggest current challenge? Have your say in Community Polls along the right column.
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.

Re: 502 Bad Gateway when updating a product with many images

502 Bad Gateway when updating a product with many images

zhengxinxin
Visitor
3 0 1

Hello, I am getting 502 bad gateway error when I update a product with many images, this is the X-Request-ID: c6e76ab2-dc2e-4391-ae61-15e956b78efb

Replies 4 (4)

ShopifyDevSup
Shopify Staff
1453 238 525

Hello @zhengxinxin,

Our team had a closer look, wanted to ask a few questions as well as share a few ideas below.
 

Have you done troubleshooting with another development or test app, including debugging manually with tools such as Postman or Insomnia?

Have you been able to consistently replicate this error? 

If not, how often does this occur? If so, does the behavior persist across multiple products, images, and/or stores?

Have you tested updating a single image, or using the Product Image resource?


After working through the info above, if you are still see this behaviour we can take another look, but will require some additional examples; 
 

  • A link to any other API documentation used as a reference
  • Steps to replicate
  • Example request body and endpoint, obscuring any sensitive data and shop URL, eg. 
    PUT /admin/api/2023-01/products/{ID}.json​
  • Request details from within the last few days, including the response header values: x-request-id and date 


We will keep an eye out for any updates here - Cheers!

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

zhengxinxin
Visitor
3 0 1

Hi,

I have tested this api many times, and some products have been updated successfully, while others have returned 502 Bad Gateway. If the request fails, it will always return failure. I guess it's because there are too many pictures associated with products. There is no problem updating a single image, but it is too slow. We hope to update all images at once through the update product api.

API documentation: https://shopify.dev/docs/api/admin-rest/2023-01/resources/product#put-products-product-id

request api: /admin/api/2023-01/products/7391940804799.json

response header: 

  • x-request-id: 4753617e-75c0-424a-935f-2a1cdbd31672
  • date: Mon, 20 Feb 2023 06:15:55 GMT

Thanks.

ShopifyDevSup
Shopify Staff
1453 238 525

Hi @zhengxinxin,

 

I checked the logs and there's no specific error message, but I notice that the connection time was well over a minute before returning a 502 response. 

 

The more data uploaded in a single request, images, (products,  variants, etc.) can increase the risk of timeouts on the platform, so I would recommend limiting the size of your requests, or trying to import images in batches with a bulk import operation.

 

Hope that helps,

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

mambro
Shopify Partner
5 0 1

Hello!

 

We just started encountering this same error, also when sending more than 50 images. The exact count where it broke was 54: 53 images got accepted.

 

We are still using an older REST API version: 2021-04. It is quite disheartening to see this happens in newer versions too. Nobody else encountered this in the past 2 years? How unlikely.

 

The error response, 502 Bad Gateway, is completely and utterly useless. It should be actionable, but all it does is give us a default error web page in HTML, of all languages. At leat provide an error in JSON or XML, conforming to the Accept header in the HTTP request.

We are a merchant selling through multiple shops. We created our own Java-based software to communicate with Shopify's Admin REST API, used successfully since 2017.