hotcakedev
hotcakedev

Reputation: 2514

How to order by lastModifiedDateTime or lastModifiedBy user displayName in Graph API?

I am trying to order documents by lastModifiedDateTime in Graph API.

But it says The property Modified is not supported for OrderBy..

I use the following API since I need to use folder-id.

enter image description here

https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{folder-id}/children?orderby=lastModifiedDateTime desc.

https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{folder-id}/children?orderby=lastModifiedBy/user/displayName desc.

But they didn't work at all.

Please let me know the correct use of Graph API.

Thank you.

Upvotes: 0

Views: 1676

Answers (1)

Allen Wu
Allen Wu

Reputation: 16458

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.

You need to get the result first and then sort it in your code. For C# you can look into this answer.

Upvotes: 2

Related Questions