我想使用Microsoft Graph SDK对Microsoft Graph API进行此查询。我想得到电子邮件地址中的域名为@something.com的所有用户。
将$filter与endsWith运算符一起使用
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没有过滤器,它工作得很好。我是不是遗漏了什么?
Refs:高级查询:https://docs.microsoft.com/en-us/graph/query-parameters Microsoft Graph SDK:https://docs.microsoft.com/en-us/graph/sdks/create-requests?tabs=CS
发布于 2021-06-25 21:34:42
如果要使用$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();https://stackoverflow.com/questions/68131584
复制相似问题