Issue in Matching Department Name while using Microsoft Graph API V1.0

跟風遠走 提交于 2020-04-18 05:43:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!