【问题标题】:Get groups by ID按 ID 获取组
【发布时间】:2018-12-11 20:23:20
【问题描述】:

为了通过 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”指定的查询过滤子句不受支持或无效。

有人可以确认一下吗?

【问题讨论】:

  • 如果你已经知道group id,为什么不直接使用/groups/{groupId} 来获取group 的详细信息呢?您的用例场景是什么?
  • 因为我想为许多组创建 webhook 订阅,而我没有兴趣为每个组订阅。

标签: azure-active-directory microsoft-graph-api


【解决方案1】:

由于错误状态不支持表达式groups?$filter=id eq '--group-id-1--' or id eq '--group-id-1--',但好消息是您可以使用/directoryObjects/getByIds endpoint 来代替按ID 检索组列表

注意:该方法在v1beta 两个版本中都可用

示例

POST https://graph.microsoft.com/v1.0/directoryObjects/getByIds
Content-type: application/json

{
    "ids":["--group-id-1--","--group-id-2--"],
    "types":["group"]
}

【讨论】:

    【解决方案2】:

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

    查询的格式是完全正确的,如果我们通过除id之外的其他属性进行过滤,例如displayName,它可以正常工作。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-04
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多