Orders API issue

changreatness
Shopify Partner
5 0 0

Hi everyone,

I executed this request query: 

 

https://myteststore-group.myshopify.com/admin/api/2019-10/orders.json?fields=financial_status,order_number,id,created_at&status=closed&financial_status=paid&limit=250&created_at_min=2020-03-22T10:00:09



It returned this response:
image.png

 

However, I still have orders on the date 2020-03-22, so when I try to execute this request:

:https://myteststore-group.myshopify.com/admin/api/2019-10/orders.json?fields=financial_status,order_number,id,created_at&status=closed&financial_status=paid&limit=250&created_at_min=2020-03-22


It returned me this response:
image.png

 

The issue is, why can't I get orders 1897-1899 when I stated that my created_at_min is 2020-03-22T10:00:09? Shouldn't this be included in the first response also?

Replies 4 (4)

hassain
Shopify Staff (Retired)
624 104 187

Hey @changreatness ,

 

As you can imagine, the reason why you are getting the results that you are getting is due to timezone.

 

Shopify's datetime values follow the ISO 8601 format, which includes a timezone offset. However in your request query, for the 'created_at_min" parameter you used the value of "2020-03-22T10:00:09" which does not include a timezone offset. Due to this the assumption is that this datetime is for the UTC timezone. In order words, your query is looking for orders that were created after March 22nd 2020, at 10:00:09 AM UTC.

 

The orders that you are seeing in your responses have the timezone offset in their "created_at" values. For example, Order 1900 has a created_at value of "2020-03-23T08:48:15+08:00" meaning that it was created at March 23rd 2020, at 8:48:15 AM in timezone UTC+8:00. This is equivalent to saying it was created at March 23rd 2020, at 00:48:15 AM at timezone UTC. 

 

If we convert your other orders to the UTC timezone we get: Order 1897 created at March 22nd at 3:35:03 AM UTC, Order 1898 created at March 22nd at 4:03:03 AM UTC, and Order 1899 created at March 22nd at 9:31:16 AM UTC. Based on this, you can see why none of these orders appear when you query for orders 'created_at_min=2020-03-22T10:00:09'

If you want to fix your request (so that these three orders appear) make sure to include the timezone offset in your datetime value always. So your request will now become:  

https://myteststore-group.myshopify.com/admin/api/2019-10/orders.json?fields=financial_status,order_number,id,created_at&status=closed&financial_status=paid&limit=250&created_at_min=2020-03-22T10:00:09+08:00

 

 

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

changreatness
Shopify Partner
5 0 0

Hi Hassain,

 

 

Thank you for replying to my question. I also did tested the query using a timezone offset (in my case, it's +08:00). However, results are still the same. The store setting is also using timezone +08:00.

hassain
Shopify Staff (Retired)
624 104 187

Hey @changreatness ,

 

Adding the timezone offset (+08:00) should resolve your issue. Please be mindful as to what API version you are using, as there are differences between how the Shopify API version for some endpoints handle timezone offsets. If you are using API version 2019-10, you should be able to see your orders when you add the +08:00 time zone offset to your datetime.

 

If you are still seeing issues, please let me know the URL of your Shopify store (e.g. {store-name}.myshopify.com) and I can investigate further. Feel free to DM me this information if you are more comfortable with that

 

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

changreatness
Shopify Partner
5 0 0

Hi Hassain,

 

I've added the timezone (+08:00) in my query below:

 

https://myteststore-group.myshopify.com/admin/api/2019-10/orders.json?fields=financial_status,order_number,id,created_at&status=closed&financial_status=paid&limit=250&created_at_min=2020-03-22T10:00:09+08:00

 

It still doesn't show the mentioned orders:
image.png'

I'm using API version 2019-10. Store also uses the same version. This is a private app.