Jim Barrett
Jim Barrett

Reputation: 467

How do you filter by file type/extension using Microsoft Graph API?

If I want to find just Excel files using the Microsoft Graph API. Is there a way to filter using odata $filter? By file type or name "endswith"?

I have tried odata filter on the name property using "endswith", "indexof", "contains" but I don't think they are supported (although "startswith seems to be).

Is there a place that states exactly what $filters are supported by the Microsoft Graph API? The docs just give a few examples and it seems like the only support odata function is "startswith".

I was able to use search as in below but I was looking for $filter support. https://graph.microsoft.com/v1.0/me/drive/root/search(q='.xlsx')

Upvotes: 3

Views: 2854

Answers (1)

Sudhi Ramamurthy
Sudhi Ramamurthy

Reputation: 2478

Filtering with endsWith is not supported for OneDrive Business Drive API. There isn't a simple way to look for files by extension today. You could try search for extension (however, it sometimes returns non-matching files/folders) -or- you can do client-side filtering. Neither options are good. I find client side filtering as the only option. This does mean you have to navigate through the pages to get a full list.

Upvotes: 2

Related Questions