Unexpected Behavior with SharePoint REST API - Issue with Sort by "ID" in Descending Order

Copper Contributor

I am encountering an unexpected behavior while using the SharePoint REST API for querying list items. Specifically, when I utilize the following REST API query to retrieve items from the "Training schedule" list in descending order:

 

/_api/web/lists/getByTitle('Training%20schedule')/items?$skiptoken=Paged%3DTRUE%26p_ID%3D0&$orderby=ID%20desc&$top=500

 

I do not receive any results.

 

However, when I use the same query in ascending order:

 

/_api/web/lists/getByTitle('Training%20schedule')/items?$skiptoken=Paged%3DTRUE%26p_ID%3D0&$orderby=ID%20asc&$top=500

 

I am able to retrieve the expected items.

 

Additional Details:

  • Removing the $skiptoken=Paged%3DTRUE%26p_ID%3D0 parameter from the query results in the descending order query working as expected.
  • I have verified that the "Training schedule" list contains items, and the REST API endpoint is correctly formatted.

 

Expected Outcome: I expect the descending order query ($orderby=ID%20desc) to return the same results as the ascending order query when using the $skiptoken parameter.

 

Request for Assistance: Could you please assist me in identifying the cause of this issue and provide guidance on how to resolve it? Additionally, if there are any alternative approaches or workarounds to achieve the desired result, I would greatly appreciate your insights.

Thank you for your attention to this matter.

0 Replies