Sorting deleted tickets using cursor-based pagination not working
Posted Feb 20, 2024
I am using the `api/v2/deleted_tickets` endpoint, and using cursor-based pagination. I have noticed that the endpoint does not respect any type of sorting. I've tried providing `sort_by`, `sort_order`, and even `sort` query parameters, and the endpoint always returns the results in the same order. With offset-based pagination, the sort is respected. Can someone help with this?
0
4
4 comments
Greg Katechis
Hi zhangjian! Could you let me know specifically which endpoint and sort method your using when this issue arises?
0
zhangjian
When using "cursor pagination", specifically when the URL contains
page[size]=100
, the sort parameter fails to perform sorting. This is a critical BUG.0
Ben Liebert
Hi there. We are having exactly the same issue. Your example didn't include the page[size] attribute, so I believe it's actually falling back to offset paging (as per https://developer.zendesk.com/api-reference/introduction/pagination/).
Your docs are pretty clear about using cursor pagination where possible, so it would be very good to be able to use sort_order/sort_by in conjunction with page[size]. For example, in our tests these both return the SAME result set:
https://xxx.zendesk.com/api/v2/deleted_tickets.json?sort_order=desc&sort_by=deleted_at&page[size]=2
https://xxx.zendesk.com/api/v2/deleted_tickets.json?sort_order=asc&sort_by=deleted_at&page[size]=2
Thank you
0
Jakub
Hello Dylan Powers


I can see that this endpoint indeed uses cursor based pagination and you can use both "sort_by" and "sort_order" where the first allows values such as "id", "subject", or "deleted_at and the second "desc" and "asc".
I performed a test using the second one: https://z3nadvocate406.zendesk.com/api/v2/deleted_tickets?sort_order=asc
We can see the order is being changed as expected, is it not the case for you?
0
Sign in to leave a comment.