繁体   English   中英

Microsoft Graph 获取所有用户异常不受支持的查询

[英]Microsoft Graph Get All Users Exception Unsupported Query

我可以将此查询提交到 Microsoft Graph Explorer,但在 C# 中,我收到一条错误消息:“Microsoft.Graph.ServiceException:“代码:Request_UnsupportedQuery 消息:不支持的查询。”

var users = await graphClient.Users
    .Request()
    .Filter("endswith(mail,'@mydomain.com')")
    .OrderBy("userPrincipalName")
    .GetAsync();

您应该发送 header ConsistencyLevel=eventual和 $count 查询参数以使其工作。

要添加 $count 查询参数,您可以使用 queryOptions。

列表查询选项 = 新列表 {
新 QueryOption("$count", true) };

var users = await graphClient.Users.Request(queryOptions).Filter("endswith(mail,'@mydomain.com')").OrderBy("userPrincipalName").GetAsync();

API 调用看起来像这样https://graph.microsoft.com/v1.0/users?$count=true&$filter=endswith(mail, '@domain.live')&$orderBy=userPrincipalName

您始终可以在 Graph Explorer 中测试这些调用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM