Hello everyone! I have been making a system that imports user's data and shows the import progress, and I've noticed a bug when sending created_at_min and updated_at_min parameters on /checkouts/count.json and /checkouts.json
My last record has:
"created_at": "2021-02-08T18:59:10+01:00", "updated_at": "2021-02-08T19:00:02+01:00",
When making a request to
/checkouts/count.json?created_at_min=2021-02-08T18:59:11+01:00 (up until 19:00:01+01:00) I get count == 1
/checkouts.json?created_at_min=2021-02-08T18:59:11+01:00 (and after) I get an empty array of items
This means that calling /count.json on a created_at date actually looks at the updated_at date and cannot return the same amount of items as calling /checkouts.json with the same parameters, which poses an issue to us since the customer can think that their import process is still ongoing, ie. there is still data to be imported although there isn't.
Another issue is with regards to the timezone.
Calling endpoints below returns the same count, 1 (although it is wrong since it is more than created_at date)
Calling endpoints below returns 1 item and 0 items respectively
Has anyone encountered these before and if so, how have they tackled this issue?
Solved! Go to the solution
This is an accepted solution.
I'd be happy to throw some light on this issue.
This post on Stack Overflow explains aptly what is going on. You can see from the Google URL with query string examples given in that post that the
+ is decoded as a space. The same behaviour happens on our end, and the
+ is converted to a space before it reaches the server side. Hence, the timezone portion is lost, and the time passed in the query of the
/checkouts.json endpoint is assumed to be the UTC timezone. The reason for the discrepancy between the 2 endpoints is that
/checkouts/counts.json uses the time passed as the shop time whereas as indicated earlier the
/checkouts.json assumes the time passed to be UTC. I understand the inconsistency between the 2 endpoints can be confusing and frustrating, and I'm going to reach out to the team in charge so the behaviour across both is consistent.
To get the expected results, your query would have to be
/checkouts/count.json?created_at_min=2021-02-08T18:59:11%2B01:00 so the time is converted to the correct UTC time on our server side.
Hopefully this information is helpful. If you have any additional questions or need clarification about this issue, don't hesitate to get back to me.
@syf_ I think I found another bug in this API.
So, I'm querying checkouts.json with updated_at parameter set to last 5 minutes. It works fine for newly created checkouts, however when I grab a checkout that was created like month ago and go to it's abandoned_checkout_url, the API do not return it. This is odd because when I check that checkout via https://shop-name.myshopify.com/admin/checkouts/[id].json - I can see that updated_at parameter is getting updated after visiting abandoned_checkout_url.
Would appreciate your insights. Thanks
Thanks for bringing this to our attention!
I've taken a look at this and confirmed that this is buggy behaviour. I've brought it to the attention of the developer team in charge, and they are going to look into this.
I'd update you when I hear back from them.
@PatrykJakubik a fix was shipped today, and you should not longer be seeing the buggy behaviour starting today. There's a small caveat to this however, existing records before the fix was pushed would still behave the same. For such orders, you would have to use the creation date to filter the orders.
Let me know if the issue still persists or if you have any questions regarding this.
Thanks for quick update!
It seems that there is still something funky going on with this API.
I'm querying checkouts.json to find a checkout with those properties:
"created_at": "2021-03-13T06:00:10-05:00", "updated_at": "2021-03-13T06:16:45-05:00",
Which translates to UTC:
I made few API calls:
Could you check that with team? Thank you.
@PatrykJakubik a fix was shipped and I believe the issue should be solved now. Just as the last time, this fix only applies to new checkouts created. Let me know if you still experience some unexpected behaviour.