Hi I’m working to pull down shipment data, and want to run the following query; however, I’m receiving an error “Unexpected Error” with the code 22. I can create requests successfully using the after parameter to move forward through the pagination, using the before parameter to go back pages causes the code 22 message
Hi Teresa, sorry for the delay, I’m trying to go back to the previous page with the before parameter using the value of start_cursor on the page I’m currently on:
Here is a request id trying to get back to page 1, with the before param with page 2 start cursor value:
request_id = 61958ad8bdebcaa3bc51387f
Thanks again, let me know if there is something i have to change, that requests returns the code 22 i mentioned,
Have a nice day,
-Nico
Hello @Raphael!
I’ve looked into it, and I can see what’s going on.
The way pagination works require you to use after with first and before with last. I will try to explain as best as possible.
In pagination, when you use the before or after cursors, you query for everything that comes before or after that cursor, respectively. So when you use the after, you need to poll for the first: #, so you get the immediate batch that follows. But when you use the before cursor, you need to use last: #, as you want to fetch the items closer to your cursor from the bulk. In this case, last would mean something like, bring me the last part of everything that comes before this cursor. If you use first+before, you would go back to page one. However, that is not supported, so that’s why you are getting that error.
Please let me know if I wasn’t clear enough.
Have a great day!
Tomas