1
votes

I have looked here https://graph.microsoft.io/en-us/docs/api-reference/v1.0/api/item_search and at the odata query parameters listed here http://graph.microsoft.io/en-us/docs/overview/query_parameters.

Can anyone offer some guidance on how to filter out folders when searching your OneDrive For Business files using the graph.microsoft.com/v1.0/me/drive/root/microsoft.graph.search endpoint and how to get orderby to work. It seems pretty simple, but I can't seem to find the syntax.

Thanks...

3

3 Answers

1
votes

The Microsoft Graph REST doesn't support to filter the folders or files directly. You can use OneDrive REST api as a workaround. Here is an example for your reference:

GET: drive/root/children?filter=folder+ne+null

And below the URL root for the service: enter image description here More detail about OneDrive REST, please refer to here. And if you want the Microsoft Graph also support this feature, you can submit the feedback from here.

1
votes

Now Microsoft Graph API supports, filtering and ordering the items in onedrive. Use the below Graph endpoint to retrieve the folders from root of the onedrive,

https://graph.microsoft.com/v1.0/me/drive/root/children?$filter=folder ne null

To order the folders in descending order, use the Graph API in below format,

https://graph.microsoft.com/v1.0/me/drive/root/children?$filter=folder ne null&orderby=name desc
0
votes

OneDrive API (and Graph API on drives) do not support filtering or ordering results from the /search API. I'll add this to our list of requested features to consider for a future update. In the mean time, you would need to do sorting / filtering of results data client side.