question

BritneyTu-4797 avatar image
0 Votes"
BritneyTu-4797 asked saldana-msft edited

Microsoft Graph sharepoint lists API $orderby not working

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?

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$orderby=lastModifiedDateTime

microsoft-graph-sites-listsmicrosoft-graph-query-parameters
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CarlZhao-MSFT avatar image
0 Votes"
CarlZhao-MSFT answered CarlZhao-MSFT commented

Hi @BritneyTu-4797

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.



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @BritneyTu-4797 Would you please provide us with an update on the status of your issue?

0 Votes 0 ·

Hi @BritneyTu-4797

Is there anything else I can help with regarding this issue?

You can comment us at any time and we will continue to follow up.

Thanks,
Carl Zhao

0 Votes 0 ·
SrinivasaRaoDarna-MSFT avatar image
0 Votes"
SrinivasaRaoDarna-MSFT answered

Hi @BritneyTu-4797,

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".

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.