Issue with GET orders Shopify API endpoint

Hoping someone can shed some light on this:

I’m trying to call the GET orders API for my public app that as I understand, is supposed to return up to 60 days worth of orders. I just want to know the average order amount for paid orders.

Here’s the endpoint I am calling:
/admin/api/2023-07/orders.json?fields=total-price&financial_status=paid

Here’s the Shopify API doc I am following:
https://shopify.dev/docs/api/admin-rest/2023-07/resources/order#get-orders?status=any

I am passing my installed app’s access token (received from the Shopify OAuth flow on installation authorization by the merchant) as the header X-Shopify-Access-Token
and I get a 400 HTTP error with the following response message:

“order”:“Required parameter missing or invalid”

The scopes on my installed app are:
write_discounts, read_discounts, read_price_rules, write_price_rules, read_orders, write_orders, write_script_tags

So per the Shopify API docs, I should be able to get a successful response to the API query.

The issue does not seem to be with the access token as I tried using an incorrect token and get this error, which is different from the one above:
“errors”:“[API] Invalid API key or access token (unrecognized login or wrong password)”

I have used the app’s access token with other Shopify API that use the X-Shopify-Access-Token header successfully.

I also have the “Protected customer data access” section checked in the Shopify Partners admin section for my app.

Any advice on this would be greatly appreciated.

Hey @Dave589

Can you confirm you’re using the GET http method?

If you’re still experiencing the issue please provide the request ID from the response headers and I can take a look from this end.

Hi @SBD ,

Yes, I am making a GET call.

Here’s the request ID:
“X-Request-ID”: “df84986f-4f10-4ed4-88c9-978014504247”

and the full response in case that helps:

{
“statusCode”: 400,
“body”: “{“errors”:{“order”:“Required parameter missing or invalid”}}”,
“headers”: {
“X-ShardId”: “307”,
“X-Sorting-Hat-ShopId”: “83049251124”,
“null”: “HTTP/1.1 400 Bad Request”,
“X-Stats-ApiClientId”: “62300618753”,
“Server”: “cloudflare”,
“X-Request-ID”: “df84986f-4f10-4ed4-88c9-978014504247”,
“X-Shopify-Stage”: “production”,
“Server-Timing”: “cfRequestDuration;dur=182.999849; processing;dur=62”,
“X-ShopId”: “83049251124”,
“X-Permitted-Cross-Domain-Policies”: “none”,
“HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT”: “1/40”,
“X-Stats-ApiPermissionId”: “643939991860”,
“X-Stats-UserId”: “”,
“X-Shopify-Shop-Api-Call-Limit”: “1/40”,
“X-Frame-Options”: “DENY”,
“Referrer-Policy”: “origin-when-cross-origin”,
“Strict-Transport-Security”: “max-age=7889238”,
“Report-To”: “{“endpoints”:[{“url”:“https://a.nel.cloudflare.com/report/v3?s=r%2FEFRyxC8jnyiVCsA%2BrdEWX2ZsQKA%2FaCysFy6SifCr0ladvPBdobbRW3xswXg0GW0vl%2Fj9BmxTqcWh4lu6sLw8VLmQ0o%2Bvsm1myWQzXHELakCRiU8P08gxbHL2Y4idzM8nb8CiWqsu4fZhRevTsiB34aAQ%3D%3D”}],“group”:“cf-nel”,“max_age”:604800}”,
“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://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 ‘self’ ‘unsafe-inline’ ‘unsafe-eval’; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Forders&source%5Bsection%5D=admin_api&source%5Buuid%5D=df84986f-4f10-4ed4-88c9-978014504247”,
“X-Shopify-API-Version”: “2023-07”,
“X-Dc”: “gcp-us-west1,gcp-us-east1,gcp-us-east1”,
“X-XSS-Protection”: “1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Forders&source%5Bsection%5D=admin_api&source%5Buuid%5D=df84986f-4f10-4ed4-88c9-978014504247”,
“Content-Type”: “application/json; charset=utf-8”,
“Transfer-Encoding”: “chunked”,
“CF-RAY”: “80c88417ea5827a2-SEA”,
“X-Content-Type-Options”: “nosniff”,
“Connection”: “keep-alive”,
“X-Download-Options”: “noopen”,
“Date”: “Tue, 26 Sep 2023 03:45:46 GMT”,
“CF-Cache-Status”: “DYNAMIC”,
“NEL”: “{“success_fraction”:0.01,“report_to”:“cf-nel”,“max_age”:604800}”,
“X-Sorting-Hat-PodId”: “307”,
“alt-svc”: “h3=”:443"; ma=86400"
}
}

Thanks!
Dave

Thanks Dave! Seeing a POST request on this end. Looks like it’s Java - can you check the code?

Hi @SBD ,

Thanks for the insight. I had GET as the method and traced it to verify it.

What happened is that I had an empty string body accidentally passed to java.net.HttpURLConnection which in turn quietly changed the request from GET to POST. I removed the empty body and it now works!

Thanks so much for your help, I don’t think I would have been able to figure out what the Shopify error message meant by “missing parameter” without your check!

Dave

1 Like