Share via

The $filter=contains feature isn’t supported

Nitzan Dudai 20 Reputation points Microsoft Intern
2026-03-30T12:10:27.57+00:00

Hi,

I’m trying to filter OneDrive DriveItems by name using $filter=contains, with the following query:
https://graph.microsoft.com/v1.0/me/drive/root/children?$filter=contains(name,'exa').
The request consistently returns Not Found - 404.

Does this indicate that string functions such as contains are not supported on the drive/root/children endpoint?

If so, is this a known limitation by design, and is there a recommended alternative for performing name-based partial matching (beyond search(q=...)?

Thanks.

Microsoft Security | Microsoft Graph
0 comments No comments

Answer accepted by question author
  1. Vasil Michev 126K Reputation points MVP Volunteer Moderator
    2026-03-30T13:14:09.5233333+00:00

    Afaik contains is not supported, but you can use startsWith() where appropriate:

    https://graph.microsoft.com/v1.0/me/drive/root/children?$filter=startsWith(name,'Book')
    

    404 error can also be returned when you have insufficient permissions, so check for that. And yeah, I know it's inconsistent, but the Graph API is a bit of a mess...

    0 comments No comments

1 additional answer

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

    $filter=contains(...) is not supported on OneDrive drive/root/children.

    OneDrive and Microsoft Graph have different levels of OData $filter support:

    • The OneDrive-specific filtering guidance shows that only comparison and logical operators (eq, ne, gt, ge, lt, le, and, or, parentheses) are supported; string functions like contains, startswith, and endswith are not listed as supported for OneDrive collections.
    • The Microsoft Graph $filter documentation does list contains, startswith, and endswith as generally supported functions, but support is resource-specific. For DriveItems under drive/root/children, contains is not supported, which is why the request fails.

    This is a by-design limitation for that endpoint.

    For partial name matching on DriveItems, the recommended alternative is to use the search API rather than $filter:

    • Use the search function on the drive:
      • GET /me/drive/root/search(q='{search-text}')
    • q is matched across several fields including filename, metadata, and file content, which covers name-based partial matching.
    • This method supports $expand, $select, $skipToken, $top, and $orderby to shape the results, but not $filter on contains(name, ...).

    So for partial name queries, the supported approach is .../drive/root/search(q='exa') rather than $filter=contains(name,'exa') on drive/root/children.


    References:

    0 comments No comments

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.