Reputation: 603
I am trying to search users based on wild card regex match using below code snippet:
var users = await graphServiceClient.Users.Request().Select(e => new {
e.DisplayName,
e.GivenName,
e.PostalCode
}).Filter(RegexMatch(DisplayName("Rob.* Thomas")
).GetAsync();
So, above should match user "Robert Thomas"and RegexMatch is currently not available in filter keyword list ,i have just used as an example to achieve this task. Below should match Robin Thomas:- Filter(RegexMatch(DisplayName("Robi.? Thomas") and also in case of UserPrincipalName search and id search etc.
I want to achieve some similar results ,but unable to find any regex search in MS Graph V1.0 documentation.
Please Help me with regex match using MS Graph API V1.0
Upvotes: 3
Views: 3228
Reputation: 22495
Microsoft Graph
V1.0 currently doesn't support wildcard like*
or%like%
though there is$search
option which Currently supported only onmessages
andperson
collections.
Work Around
:
You could try bellow way
var users = await graphServiceClient.Users
.Request()
.Filter("startswith(displayName,'Rob') and startswith(UserPrincipalName ,'Thomas')")
.Select( e => new {
e.DisplayName,
e.GivenName,
e.PostalCode
})
.GetAsync();
Note:
You can bind multiple and
, or
clause to execute your custom search.
Hope it would help.
Upvotes: 2