We have a requirement of filtering the Users based on partial search on some field

BANERJEE Biswarup 0 Reputation points
2024-04-19T09:34:40.9866667+00:00

We want to fetch a user based on partial search for example if this is the exact search
https://graph.microsoft.com/v1.0/users?$filter=mailNickName eq 'NLBBAN1'
This should be the partial search
https://graph.microsoft.com/v1.0/users?$filter=contains(mailNickName , 'BBAN')
or

https://graph.microsoft.com/v1.0/users?$filter=mailNickName has 'BBAN'

but none of them is working. Please let me know the correct way of doing the same.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,836 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 97,076 Reputation points MVP
    2024-04-19T18:05:22.1133333+00:00

    The Graph API supports StartsWith, EndsWith and Contains operators for this, as detailed here: https://learn.microsoft.com/en-us/graph/filter-query-parameter?tabs=http#operators-and-functions-supported-in-filter-expressions

    Be aware that not every property will support said operators though.