question

FrancescoCarraro-4351 avatar image
0 Votes"
FrancescoCarraro-4351 asked saldana-msft edited

graph onedrive search + orderby

I'm trying to execute the following query for retrieving a flat list of pictures from my onedrive:

https://graph.microsoft.com/v1.0/me/drive/root/search(q='jpg')?select=id,lastModifiedDateTime,createdDateTime,name&orderby=lastModifiedDateTime+desc

I'm facing the issue related to the orderby clause that doesn't work.

Other info: I'm using a personal account for test but I'm would like to use the query in an app that use personal delegated access to onedrive.

Any solution?

Thanks in advance for any help

microsoft-graph-filesmicrosoft-graph-searchmicrosoft-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.

dkoeder avatar image
0 Votes"
dkoeder answered

Try changing the +desc to %20desc.

 https://graph.microsoft.com/v1.0/me/drive/root/search(q='jpg')?select=id,lastModifiedDateTime,createdDateTime,name&orderby=lastModifiedDateTime%20desc
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.

FrancescoCarraro-4351 avatar image
0 Votes"
FrancescoCarraro-4351 answered dkoeder commented

already tried. It doesn't work. It seems that orderby clause doesn't work with 'search'....when I try a query without the 'search' clause, the results are correctly ordered

· 1
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.

Have you tested it against the sample account at https://developer.microsoft.com/en-us/graph/graph-explorer? It sorted correctly for me, when I tested it there, even with the 'search(q='jpg')'.

0 Votes 0 ·
FrancescoCarraro-4351 avatar image
0 Votes"
FrancescoCarraro-4351 answered FrancescoCarraro-4351 commented

Hi,
thanks for the answer...it seems you're right: by using the sample account results are correctly ordered....so....is it a permission issue? do you know which kind of permission is required for having results ordered in the right way? or is it something else?

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

Based on my testing, this appears to sort properly with Work or School accounts (i.e. querying OneDrive for Business). When using a personal account (i.e. querying consumer OneDrive) it appears to not order the results as expected.

0 Votes 0 ·

thanks for your reply.
if so this is really a big issue for me....also this kind of difference in behaviour depending on the account type it's not documented....really a
big mess.....I have to find an alternative solution for exploring recursively the OneDrive account.

0 Votes 0 ·