502 Bad Gateway error when retrieving products with presentment prices

Highlighted
Tourist
4 0 2

Hello,

 

We're getting many 502 Bad Gateway errors when retrieving products with presentment prices from some stores using REST Product API. We tried to reduce the "limit" parameter down to 5-10 products per page, which made products export in our app very slow. But even that does not help in some cases. For example, these request returned 502 Bad Gateway error when trying to get only 5 products:

 

X-Request-ID: e5bec2be-3ca2-49e6-ad68-0d5358378c28

 

Is there a problem with Shopify API and what would you recommend as a solution to this problem?

 

Thank you, 

Sergei

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

Hi @SearchaniseTeam ,

 

The 502 Bad Gateway error you are seeing on the "products.json" REST Admin API is a known issue that is on our radar. So far from our investigation this issue seems to be limited to a few API clients and merchants only. If you could provide me with your app name (or API client ID), and the myshopify.com URL of the merchants you are seeing this error for, then that would be helpful to our on-going investigation. Feel free to DM me this information if you do not feel comfortable sharing it on the thread. 

 

I will keep this thread informed if there are any updates to this issue. In terms of workarounds so far, here are two that we are aware of:

  • Dropping the header "X-Shopify-Api-Features: include-presentment-prices" or the query string parameter of "include_presentment_prices=1" from your API request
  • Moving away from the "products.json" REST Admin API endpoint and using GraphQL to get this data instead  

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Tourist
4 0 2

Thank you for the suggested workarounds. We will consider them carefully.

 

Our app name is "Smart Search & Instant Search" (API Client id: 543e5094f4dc166bd6de54ff98c7e80e). Here are some of the store URLs we are seeing this error for:

 

feasttradingco.myshopify.com

cbikeslc.myshopify.com

jstechnics.myshopify.com

original-film-art.myshopify.com

ponies-and-**bleep**.myshopify.com

 

I hope it will be helpful.

1 Like
Highlighted
New Member
1 0 0

Hello,

 

We have the same issue on our client shop. After removing the header X-Shopify-Api-Features: include-presentment-prices, our script works perfectly well.

Keep the thread opened to inform any updates from your team.

Thank you all.

 

 

0 Likes
Highlighted
New Member
2 0 2

This is still an on-going issue. Removing the presentment-prices header does resolve it, but that isn't a good workaround for stores that use multi-currency features.

Once thing that we have noticed is that it tends to occur only when a product has many variants, in this case 70-80. I suspect the query to get presentment pricing for all of those variants is where it's falling over.

Our next move is to switch our code to use the GraphQL API instead in the hopes that we can get presentment prices even on products with a large number of variants, I will update this thread with the results.

1 Like
Highlighted
New Member
2 0 2

An update for anyone who lands here with the same issue, it seems the shop has all of the currencies enabled, and that means when you are trying to pull presentment prices Shopify's API just can't handle that much nested data, in this case with a few dozen variants and a couple hundred price/currency value pairs per variant, you can kind of see why.

The GraphQL API doesn't solve this, it does exactly the same thing (502 error). If you just grab one variant and the first 50 presentment prices, you will be able to see what's up:

{
    product(id: "gid://shopify/Product/<ProductID>") {
        title
        description
        onlineStoreUrl
        variants(first:1) {
            edges {
                node {
                    displayName
                    presentmentPrices(first:50) {
                        edges {
                            node {
                                price {
                                    amount
                                    currencyCode
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

 

 

1 Like