问题
I am using below code to match Department Name:
string departmentName = "Admin";
var departmentPeoples = await graphServiceClient.Users.Request().Filter($"department eq '{departmentName}'").Select(u => new {
u.DisplayName,
u.MobilePhone,
u.BusinessPhones,
u.UserPrincipalName
}).GetAsync();
This works, but when my search string is Admin & IT
,it doesn't work because of & sign.
I tried using var departmentname ="Admin \& IT"
But still it shows error:
Microsoft.Graph.ServiceException: 'Code: BadRequest Message: Invalid filter clause or string doesn't match.
回答1:
Try to convert "&" to "%26" manually.
You could use var departmentname ="Admin %26 IT"
in this case.
来源:https://stackoverflow.com/questions/60603198/issue-in-matching-department-name-while-using-microsoft-graph-api-v1-0