简体   繁体   中英

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')

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM