小组成员-Orderby

时间:2019-06-21 21:30:06

标签: c# microsoft-graph

我正在尝试列出组成员并按displayName对其进行排序。

此URL引发错误:     string.Format("https://graph.microsoft.com/v1.0/groups/{0}/members?$orderby=displayName", groupId);

{
    "error": {
        "code": "BadRequest",
        "message": "OrderBy not supported.",
        "innerError": {
            "request-id": "c75a9b12-9887-49a8-b5d9-329f4bdec4f4",
            "date": "2019-06-21T21:25:19"
        }
    }
}

此URL返回结果,但不应用任何种类的

return string.Format("https://graph.microsoft.com/v1.0/groups/{0}/members/microsoft.graph.user?$orderby=displayName", groupId);

文档指出应支持所有OData查询参数https://docs.microsoft.com/de-de/graph/api/group-list-members?view=graph-rest-1.0&tabs=cs

有什么办法可以解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

根据我的理解,您需要以下权限和请求格式:确保您具有以下权限:

需要权限:

要读取Application Permission之后的群组列表。您可以检查here

enter image description here

获得同意 选择Group.Read.All的应用程序权限后,请记住单击Grant admin consent for tenant,如下所示:

enter image description here

PostMan测试:

请求网址: https://graph.microsoft.com/v1.0/groups?$orderby=displayName

enter image description here

记住点:

检查您的令牌是否具有上述权限。您可以在https://jwt.io/

上解码令牌

组成员:

如果要从组中获取所有成员,则必须按组对象ID进行过滤,如下所示:

https://graph.microsoft.com/v1.0/groups/YourGroupObjectId/members

它将获取该组中的所有成员,并按dispalyName进行过滤。请参见以下屏幕截图:

enter image description here

注意:由于其已经按显示名称排序,因此您需要传递OrderBy参数。因此,请摆脱您的$orderby=displayName参数,然后尝试我的示例。

相关问题