Share via

Filter on items name in /items doesn’t react.

ANAS 0 Reputation points
2026-03-03T11:55:16.0966667+00:00

Hi , i’am having a hard time filtering on my items names using graph api call via postman, and the docs don’t seem to cover that.

when i call

https://graph.microsoft.com/v1.0/sites/xxxx.x,xxxx,xxxx/drives/xxxx/items?$filter=contains(name,'test')&$top=1

the result brings back the first random folder it fetches all the time.

only the top 1 is working.

i tried eq, startswith etc… nothing seems to work on my items.

can you please tell me why ?

it seems that i can not use search api too, since i only have selected Sites as role.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2026-03-03T11:55:28.17+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Filtering on the name property in this scenario is not supported the way the request expects.

    For OneDrive for Business and SharePoint Online, the optimized and supported filterable properties for items are limited. For drive items, filtering is optimized for properties such as:

    • createdDateTime (with gt, ge, lt, le)
    • lastModifiedDateTime (with gt, ge, lt, le)
    • file
    • folder
    • image
    • video
    • deleted

    In OneDrive for Business, SharePoint Online, and SharePoint Server 2016, filtering is only supported on the name and url properties in the context of search results, not for arbitrary item listing endpoints. The example where filter on name is used is specifically on a search request:

    GET /drive/root/search(q='vacation')?filter=image ne null and file ne null
    

    This means:

    • $filter on name is not guaranteed to work or be efficient on /items collections.
    • Using contains(name,'test'), startswith(name, ...), or eq on name in /items can lead to unexpected behavior, including apparently random results or ignoring the filter.

    Because of these limitations, the behavior observed (only $top=1 being honored and the filter not affecting results) is expected for that endpoint.

    To filter by name reliably, use the search API over drive items (for example, search on a drive or drive root) and then apply supported filters (such as file ne null and image ne null) on the search results, rather than on /items directly. Note that access to the Microsoft Search API and its scopes/roles is required; if only Sites role is granted and the Search API cannot be used, there is no supported way in this context to do server-side contains/startswith filters on item names under /items.


    References:


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.