Some time not getting orders details in Shopify API call

When I am trying to get order details using Shopify API to call then sometimes I’m getting a response as following.

Array
(
    [headers] => Array
        (
            [status] => HTTP/2 404 
            [date] => Wed, 07 Apr 2021 08:52:10 GMT
            [content-type] => application/json; charset=utf-8
            [x-sorting-hat-podid] => 73
            [x-sorting-hat-shopid] => 14698742
            [vary] => Accept-Encoding
            [referrer-policy] => origin-when-cross-origin
            [x-frame-options] => DENY
            [x-shopid] => 14698742
            [x-shardid] => 73
            [x-stats-userid] => 
            [x-stats-apiclientid] => 2441839
            [x-stats-apipermissionid] => 80515104842
            [http_x_shopify_shop_api_call_limit] => 1/40
            [x-shopify-shop-api-call-limit] => 1/40
            [x-shopify-api-version] => 2020-04
            [x-shopify-api-version-warning] => https://shopify.dev/concepts/about-apis/versioning
            [strict-transport-security] => max-age=7889238
            [x-shopify-stage] => production
            [content-security-policy] => default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopifycdn.net https://checkout.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=show&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Forders&source%5Bsection%5D=admin_api&source%5Buuid%5D=45a36481-6375-47c9-a49f-20478cf16d9d
            [x-content-type-options] => nosniff
            [x-download-options] => noopen
            [x-permitted-cross-domain-policies] => none
            [x-xss-protection] => 1; mode=block; report=/xss-report?source%5Baction%5D=show&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Forders&source%5Bsection%5D=admin_api&source%5Buuid%5D=45a36481-6375-47c9-a49f-20478cf16d9d
            [x-dc] => gcp-asia-southeast1,gcp-us-east1,gcp-us-east1
            [x-request-id] => 45a36481-6375-47c9-a49f-20478cf16d9d
            [set-cookie] => _shopify_fs=2021-04-07T08%3A52%3A10Z; Expires=Thu, 07-Apr-22 08:52:10 GMT; Domain=the-lost-breed.myshopify.com; Path=/; SameSite=Lax
            [cf-cache-status] => DYNAMIC
            [cf-request-id] => 094d213ea100002e2f1e8fe000000001
            [expect-ct] => max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
            [server] => cloudflare
            [cf-ray] => 63c204aa9f7c2e2f-BOM
            [alt-svc] => h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
        )

    [response] => {"errors":"Not Found"}
)

The application has all orders access.
I see this issue happened for multiple stores.

So, Have any idea why this happening and how can I prevent it?

Hi @identix ,

After checking our logs using the x-request-id in your response header, it looks like you didn’t request the read_all_orders scope during the OAuth authorisation of your app, and the order you’re trying to access was created in 2016. I see you have the read_all_orders scope enabled for your app, but you still need to request this scope during OAuth. If a merchant installed your app before that scope was granted, they would have to re-auth by re-installing your app because you’re requesting new permissions.

If you have already done the above and you’re still getting 404s, let me know and I can dig into this further.

Best,
Seth.

Thanks for the reply

The app is installed by December 9, 2018 at 6:10 am.

So please check about this and update us.

I am facing the same issue for multiple stores.

@identix I believe your app was granted the read_all_orders scope on April 9, 2019. Merchants who had already installed your app by then would have needed to re-auth your app again because you requested a new scope during the OAuth process. I’m sure if you check all shops where you’re seeing this error, they would be ones that were installed before you requested the new scope. All the merchant has to do is click on the install link again (no need to uninstall), and that scope will be added.

Let me know if you have any more questions.

Thanks,
Seth.