Search code examples
c#azure-active-directorymicrosoft-graph-api

Is there any Filter condition for string "contains" in MS Graph API V1.0


I am using below code to find users in Department :

string searhString="IT Admin Onsite";

var departmentPeoples = await graphServiceClient.Users.Request().Filter($"department eq '{searchString}'").Select(u => new {
                        u.DisplayName,
                        u.MobilePhone,
                        u.BusinessPhones,
                        u.UserPrincipalName
                    }).GetAsync();

But, i want to search all Department which contains ,hence my searchString will be

string searhString="Admin";

I have tries startswith ,but that will work only when my searchString is "IT" in the given example code. How to achieve this Task?

Please Help.


Solution

  • I'm afraid that contains is not supported on any Microsoft Graph resources.

    See details here.

    Note: The following $filter operators are not supported for Azure AD resources: ne, gt, ge, lt, le, and not. The contains string operator is currently not supported on any Microsoft Graph resources.

    Currently you could get all the results and filter with the Department in your C# code.