[英]Get all users with a specific email domain using Microsoft Graph SDKs
我想使用 Microsoft Graph SDK 对 Microsoft Graph API 进行此查询。 我想让电子邮件地址中域的所有用户都是@something.com。
使用带有endsWith 运算符的$filter
GET ../users?$count=true&$filter=endsWith(mail,'@something.com')
我尝试了以下代码行:
var users= await _graphServiceClient.Users.Request().Filter("mail '@something.com'").Select(u => new {
u.Mail,
u.DisplayName,
}).GetAsync();
我得到的错误是:
Microsoft.Graph.ServiceException: 'Code: BadRequest
Message: Invalid filter clause
没有过滤器,它工作正常。 我错过了什么吗?
参考:高级查询: https : //docs.microsoft.com/en-us/graph/query-parameters Microsoft Graph SDKs: https : //docs.microsoft.com/en-us/graph/sdks/create-requests?标签= CS
如果您想使用$count
查询参数,您需要添加具有eventual
值的ConsistencyLevel
标头。
GET /users?$count=true&$filter=endsWith(mail,'@something.com')
ConsistencyLevel: eventual
在 C# 中为请求指定标头选项和查询选项:
var options = new List<Option>();
options.Add(new HeaderOption("ConsistencyLevel", "eventual"));
options.Add(new QueryOption("$count", "true"));
向过滤器添加endsWith
运算符。
var users = await _graphServiceClient.Users
.Request(options)
.Filter("endsWith(mail,'@something.com')")
.GetAsync();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.