首页 文章

按ID获取组

提问于
浏览
0

要按ID检索特定组,我使用此请求:

https://graph.microsoft.com/v1.0/groups?$filter=id eq 'xxxxx'

现在我对获得许多组感兴趣,但看起来过滤器不支持多个元素 . 当我尝试这个:

https://graph.microsoft.com/v1.0/groups?$filter=id eq 'xxxxx' or id eq 'yyyy'

它返回此错误:

为资源“组”的属性“id”指定了不受支持或无效的查询过滤器子句 .

有人可以证实我这个吗?

2 回答

  • 0

    是的,你是对的 . 我可以在我身边重现你的问题,不知道为什么,但它应该被设计成这样 .

    查询的格式是完整的,如果我们使用 id 之外的其他属性进行过滤,如 displayName ,它可以正常工作 .

    https://graph.microsoft.com/v1.0/groups?$filter=displayName eq 'xxxx' or displayName eq 'xxxx'
    
  • 0

    由于错误声明表达式 groups?$filter=id eq '--group-id-1--' or id eq '--group-id-1--' 不受支持,但好消息是您可以利用/directoryObjects/getByIds endpoint代替通过其ID检索组列表

    注意:该方法适用于v1和beta版本

    Example

    POST https://graph.microsoft.com/v1.0/directoryObjects/getByIds
    Content-type: application/json
    
    {
        "ids":["--group-id-1--","--group-id-2--"],
        "types":["group"]
    }
    

相关问题