Hello Abhilasha Sharma
Thank you for reaching out to Microsoft Support!!
Based on your query, filtering items in a OneDrive or SharePoint drive using Microsoft Graph API requires the correct endpoint and supported filter parameters.
The $filter
query parameter is not supported for items
under drives/{drive-id}/items
. That’s why your filter is not working correctly.
To filter files, you should query the /drive/root/search(q='query') endpoint for name-based searches or use /drive/root/children along with $filter
for metadata-based filtering.
Filtering by name:
The $filter
query does not work on the /items
endpoint. Instead, use the search feature:
https://graph.microsoft.com/v1.0/drives/{driveid}/root/search(q='TEST')
This will return files containing "TEST" in their name.
Note: Filtering by name using the search endpoint does work, but it has some limitations. The search(q='TEST') query will return items that contain "TEST" in their name, but it does not support exact matches or advanced filtering like $filter
**
Filtering by lastModifiedDateTime:**
If you need to filter items by lastModifiedDateTime, use /drive/root/children with $filter
:
https://graph.microsoft.com/v1.0/drives/{driveid}/root/children?$filter=lastModifiedDateTime ge 2025-04-01T00:00:00Z and lastModifiedDateTime le 2025-04-30T23:59:59Z
Alternatively, you may need to retrieve all items and filter the results on your client-side, as filtering on lastModifiedDateTime
might not be directly supported.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.