Internal Server Error in Orders API (REST Admin API )

Hello Shopify Community, We have an app listed in shopify marketplace for tracking purpose. We are making use of Shopify Orders API to capture the order details in the thank you page. This API call is to collect item level details mainly tax details of each item. But, we are seeing some issues lately with the api:

Many clients who have their stores on Shopify using our app and even in some of our test stores, we are observing frequent 500 Internal Server Error as a response to the order’s api call. In order to handle this, we have tried to optimize API call by retrying it once again after 1 second delay, there is improvement in performance now, but we are still seeing good percentage of errors even after implementing this. Could you help us with why is this happening and how do we resolve this?

Hi @cj_dev

A 500 is different from a 429 response. That means a general exception occurred on Shopify’s end, it might not even be traffic related.

The response should include a unique ID that you can share to give Shopifolk more context about these errors.

It always helps to share your request details as well (without sensitive access tokens of course).

The more details you provide, the easier job you make it for the Shopify team and the faster of an answer you’ll get.

Sure, below is how we are trying to call Shopify Orders API:

const requestOptions = {
                method: 'GET',
                headers: {
                    'X-Shopify-Access-Token': accessToken
                }
            };
            let response = await fetch(`https://${shop}/admin/api/2025-01/orders/${orderId}.json`, requestOptions);

            if(!response.ok) {
                console.log(`Retrying orders API for shop: ${shop}`);
                //wait for 1 sec before retry
                await new Promise(resolve => setTimeout(resolve, 1000));
                response = await fetch(`https://${shop}/admin/api/2025-01/orders/${orderId}.json`, requestOptions);

                if(!response.ok){
                    console.error(`Error fetching order details from API for shop: ${shop}`);
                    return createResponse('500', 'Internal Server Error', { error: 'Error fetching order details from API' });
                }
            }

We are not capturing response status code currently but we just check for successful responses to handle error. We observe in many cases, the response is not successful. So, we are running into issues reading the order details.

Hi @cj_dev,
from what i see you are already aware that you are not capturing the real error, my first advice is start to capture and try to handle the real error.

you could have your own reason to Masquerade every errors as a generic “Internal Server Error” but you need to handle the real reason of your problem :slight_smile:

Hi,

We have been working on getting to the root cause and find the exact error from Shopify. We are now capturing the response status code to see why its failing and this is what we observed:

In a time frame of 2.5 hours, our application has made a total of 804 API calls to the Shopify Orders API for various shops. We found that 88 of those calls has returned 404 as the error code. Rest of it is 200 successful, there seems to be no other error codes.

We went through the Shopify documentation to see what it means,

Although the number of errored calls are less, it is important for us to get data from every single one of these calls. Do you know why this is happening and why is Shopify Orders API not consistently available?