AllTech
AllTech

Reputation: 603

Microsoft Graph API user search with Select & Filter condition doesn't search users with given condition

I am using below code to get users with matched Display Name:

var users1 = await graphServiceClient.Users.Request().Select(e => new {
    e.DisplayName,
    e.GivenName,
    e.PostalCode
}).Filter($"DisplayName contains 'Robert'")
.GetAsync();

But ,it doesn't show any result. I am also trying to search using wildcards or startswith i.e Filter(startswith('Robert')) But this also doesn't work.

Please help.

Upvotes: 2

Views: 3266

Answers (1)

Md Farid Uddin Kiron
Md Farid Uddin Kiron

Reputation: 22533

You could try following way

var users1 = await graphServiceClient.Users
    .Request()
    .Filter("startswith(displayName,'Robert')")
    .Select( e => new {
             e.DisplayName,
             e.GivenName
             })
    .GetAsync();

Please refer to Official Document for further details.

Upvotes: 1

Related Questions