Shipments Query Giving Unexpected Error, Code 22

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

Request ID : 61688ec3251001adfa08f34a

GraphQL Response :

{'orders': {
    'request_id': '61688ec3251001adfa08f34a', 
    'complexity': 51, 
    'data': None}
    'message': 'Unexpected Error', 
    'operation': 'orders', 
    'field': 'data', 
    'request_id': '61688ec3251001adfa08f34a', 
    'code': 22

Thanks, raphael

Can you send a request ID for a successful after?

Hi theresa, sorry for the late response, let me send you the request ids for successful reuqests with the after param:


  • first page request_id → 616f6bdad346b3755a547eb4
  • second page request_id → 616f6beb88acc9a280df7d0e
  • third page request_id → 616f6bf728a08cb8b3e7a66b

Trying to use before token on third page and getting 22 error:

  • request_id → 616f6c1609155d944b5a06ac

Hi Raphael,
I think that the issue is that you are looking for records before first. If you change the first to last, you can do a before.

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,

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!