Pagination request fails: INVALID_REQUEST_ERROR - Pagination cursor is not compatible with this request

I can retrieve customers in my Python application using Square SDK call customers.search_customers() if I retrieve all of them in one call. But when I set “limit” parameter to any value that causes pagination and I use the cursor value in the previous response to send the request again to retrieve more customers, I get the following error.

[{‘category’: ‘INVALID_REQUEST_ERROR’, ‘code’: ‘INVALID_VALUE’, ‘detail’: ‘Pagination cursor is not compatible with this request.’, ‘field’: ‘cursor’}]

I have tried many variations on setting the “cursor” value, have verified that I am sending the same cursor value that was received in previous response, and have verified that my requests don’t change at all except the addition of the cursor parameter. Can you please help me figure out what might be wrong with my API requests?

Additional info: I am using V2 API on sandbox with application ID: sandbox-sq0idb-ewExpZ_WdzmzDqHP0cZU6Q In case you want to check the logs, one (of many) requests failed on November 18 1:22pm Pacific Time.

My request parameters are
{‘limit’: 1, ‘query’: {‘filter’: {‘updated_at’: {‘start_at’: ‘2020-01-01T00:00:00Z’, ‘end_at’: ‘2020-11-18T13:04:49’}}, ‘sort’: {‘field’: ‘CREATED_AT’, ‘order’: ‘ASC’}}}

It looks like you’re setting the end_at at the current time or something. The initial request (in one example) used end_at: "2020-11-18T13:22:01". However, the next request including the cursor used end_at: "2020-11-18T13:22:03", which is not the same, which means it’s a different request. All the request parameters must be the same or the cursor will not work.

Oh yes, that worked. I thought of end_at as current time but the backend system sees this as just another time. Thanks for the clarification. Much appreciated.

1 Like