Orders - created_at_min returns different time zone

Solved
Highlighted
New Member
2 0 0

Hi,

I'm trying to fetch orders using the create_at_min filter but it looks the API is using the other timezone.

I was tried with like below API request:
admin/api/2020-04/orders.json?created_at_min=2020-06-05T18:00:00+09:00

The response was empty:

{
    "orders": []
}

After that, I was tried again with like below request:
admin/api/2020-04/orders.json?created_at_min=2020-06-05T09:00:00+09:00

Now, I could get the response like below, but it seems the "created_at" time has the after time of "2020-06-05T18:00:00+09:00", which I was tried before.

{
    "orders": [
        {
            "id": 1234567890123,
            "email""user@example.com",
            "closed_at"null,
            "created_at""2020-06-05T18:50:57+09:00",
            "updated_at""2020-06-05T18:50:57+09:00",
            "number"3,
            ....
        }
    ]
}
I think this issue is same thing as below:
It looks the thread was solved, but not for me.
 
Should I have to use the other time zone? or should I need to wait for supporting?
I'd like to know how people who have dealt with similar problems have solved them.
0 Likes
Highlighted
Shopify Staff
Shopify Staff
619 76 139

This is an accepted solution.

Hey @kzzz,

Do you know if your client is encoding the URL before it's sent? When a timezone contains the + symbol, it needs to be encoded when sent as part of the URL, otherwise it's interpreted as a space which causes the timestamp to be ignored.

 

An easy way to test is to manually replace + in your URL with the encoded version  %2B and try sending the call again.

admin/api/2020-04/orders.json?created_at_min=2020-06-05T18:00:00%2B09:00

If you get the expected results, this suggests your client wasn't encoding the URL previously.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Highlighted
New Member
2 0 0

Hi @_JB,

Thank you for your response!
I'm sorry for the delay in replying.

I tried the method you pointed out and it worked!

As for the cause, I was using JavaScript function `encodeURI()` to convert URIs, but I needed to use `encodeURIComponent()` to convert `+` to `%2B` .

I couldn't solve the problem by myself, so this helped me a lot. Thank you so much!

0 Likes