Microsoft Graph sharepoint lists API $orderby not working

Britney Tu 1 Reputation point

I tried the following for sharepoint list items. It returns with a 200 response but not sorted properly by last modified datetime. Does microsoft currently support oDATA parameter $orderby for sharepoint list?


Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
1,332 questions
Microsoft Graph Site Lists API
Microsoft Graph Site Lists API
A Microsoft API that "supports access to SharePoint sites, lists, and drives; read-only support for site resources; read-write support for lists, listItems, and driveItems; and address resources by SharePoint ID, URL, or relative path.
328 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,461 Reputation points

    Hi @Britney Tu ,

    Query parameter $orderby can be applied on the expanded properties of fieldvalueset, and usage of the is not recommended large lists.

    Following is an example snippet:

    /sites/{site-id}/lists/{list-id}/items?$expand=fields&$orderby=fields/Modified desc  
    Prefer: HonorNonIndexedQueriesWarningMayFailRandomly  

    Note: Please note that Prefer: HonorNonIndexedQueriesWarningMayFailRandomly should be added in the Request headers, but be warned that such queries may fail on large lists.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have any further questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

  2. CarlZhao-MSFT 23,361 Reputation points

    Hi @Britney Tu

    Please see this document: Sorting collections:

    Note that in OneDrive for Business and SharePoint Server 2016, the orderby query string only works with name and url.

    Sharepoint online is actually OneDrive for Business.

    So filtering by lastModifiedDateTime is not supported in this case. It is supported for OneDrive Personal.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.