HTTP Request (API, Orders)

Solved

HTTP Request (API, Orders)

Moussa1997
Visitor
3 0 0

Dear Shopify Developers & Experts,

As we were writing a Python script to retrieve Orders from our online store, we faced a confusing issue.

The HTTP request works for some months only and returns an empty response for other months (using the same request). Please find below the HTTP request URL:

url = f'https://{api_key}:{password}@myOnlineStore.com/admin/api/2021-07/orders.json&status=any'

If we change 07 to 05 for example it doesn’t return any orders, and this happens for several other months, even though there are orders during these months.

Kindly let me know if you need further information or if I’m doing something wrong.

Thank you in advance.

Youssef

Accepted Solution (1)
csam
Shopify Staff (Retired)
267 40 51

This is an accepted solution.

Hi @Moussa1997 

The 2021-07 or 2021-01 part of the URL is referencing the version of the API being requested, not the date range of the orders themselves. You'll want to use the created_at_min/max or updated_at_min/max as parameters for requesting specific order dates.

So, for example: 

/admin/api/2021-01/orders.json?updated_at_max=2021-07-31T00:00:00-04:00

and 

/admin/api/2021-07/orders.json?updated_at_max=2021-07-31T00:00:00-04:00

Are requesting the same information, but they are requesting different versions of the API. 

Our API releases a new version each quarter:

21-08-stvyz-twtw8

 

You can read more about our versioning system here: https://shopify.dev/api/usage/versioning

I would also recommend following our API Changelog here: https://changelog.shopify.com/ This will let you know of any large changes to the API that might affect your app in future.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 5 (5)

stephenJCA
Tourist
4 1 1

Are you trying to access orders made more than 60 days ago?  I believe you need to request read_all_orders through your app settings to see orders over 60 days old.  https://shopify.dev/api/usage/access-scopes

Moussa1997
Visitor
3 0 0

I don't think this is the issue since we were able to get orders from July 2021 but not August 2021 AND we also got orders from some of 2020's months.

csam
Shopify Staff (Retired)
267 40 51

Hi @Moussa1997 

If you try doing something like 

/admin/api/2021-01/orders.json?created_at_max=2021-06-31T15:57:11-04:00

Are you able to see older orders? 

You can see more examples of different order request on our Docs page here: https://shopify.dev/api/admin/rest/reference/orders/order

To learn more visit the Shopify Help Center or the Community Blog.

Moussa1997
Visitor
3 0 0

Hi @csam,

thank you for your reply. Yes, I did and unfortunately, I'm still getting the same error:

{'errors': 'Not Found'}

 In 2021, only Jan, April & July return the orders. However, all the other months return the same response mentioned above.

I really don't know the reason behind this inconsistency, I also tried using status=anycreated_at_max as you suggested but it's still not working.

 

csam
Shopify Staff (Retired)
267 40 51

This is an accepted solution.

Hi @Moussa1997 

The 2021-07 or 2021-01 part of the URL is referencing the version of the API being requested, not the date range of the orders themselves. You'll want to use the created_at_min/max or updated_at_min/max as parameters for requesting specific order dates.

So, for example: 

/admin/api/2021-01/orders.json?updated_at_max=2021-07-31T00:00:00-04:00

and 

/admin/api/2021-07/orders.json?updated_at_max=2021-07-31T00:00:00-04:00

Are requesting the same information, but they are requesting different versions of the API. 

Our API releases a new version each quarter:

21-08-stvyz-twtw8

 

You can read more about our versioning system here: https://shopify.dev/api/usage/versioning

I would also recommend following our API Changelog here: https://changelog.shopify.com/ This will let you know of any large changes to the API that might affect your app in future.

To learn more visit the Shopify Help Center or the Community Blog.