Im trying get latest events but i'm unable to change order - so when I limit for 250 PCS - I got responded with oldest not newest.
and query REST via:
$shop->api()->rest('GET', '/admin/events.json',['limit' => 250, 'order' => 'created_at desc']);
and response (expected first element of array to be dated from 06.24 but here is oldest.
(am I doing that query order created_at dec wrong way?)
Solved! Go to the solution
there is two solutions for you.(if i am not wrong you need new orders but shopify rest api give you old)
one solution is paging please try pagination in your request.
second solution is "since_id" tag in your request.(since_id always give you orders after mentation since_id value)
please tell me which is good and if you need more info please tell me which one is good for you.
Thank You for quick reply,
We are talking about events:
Problem with them - they are triggered by multiple actions and quickly go to crazy amount of records, on my developing store after adding couple fake data I got event count of
count" => 8915
Fetching all of them require using pagination and for that 9000 require making 36 requests.
So i really what i need is just order_by via id or date and limit for example 100 records.
For now I test using data:
$shop->api()->rest('GET', '/admin/events.json',['limit' => 250, 'created_at_min' => '2020-07-22 12:30:00+00:00']);
but problem witch created_at_min will not return any results if they not existing in that period, so i should change date backward until I get 250 results making another requests.
I hope You understand my problem and give other advice?
This is an accepted solution.
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.
If you get the expected results, this suggests your client wasn't encoding the URL previously.
why not use since_id. when you get your response save your last id in Db and next just start from that id.
i will prefer since_id more then date but in my case created_at_min is also worked good.