如何在数组对象上构建 Ms 图 api 查询过滤器?

How to build a Ms graph api query filter on array object?

我计划利用 List Groups Ms graph API 列出我组织中的 O365 组,然后为 Yammer 组筛选它们。

当我在图形资源管理器中使用此 API 时,它 return 跟随响应对象。

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups",
  "@odata.nextLink": "https://graph.microsoft.com/v1.0/groups?,
  "value": [
    {
      "id": "",
      "description": "",
      "displayName": "",
      "groupTypes": [
        "Unified"
      ],
      "isAssignableToRole": null,
      "mail": "",
      "mailEnabled": true,
      "mailNickname": "",
      "onPremisesDomainName": null,
      "onPremisesLastSyncDateTime": null,
      "onPremisesNetBiosName": null,
      "onPremisesSamAccountName": null,
      "onPremisesSecurityIdentifier": null,
      "onPremisesSyncEnabled": null,
      "preferredDataLocation": null,
      "proxyAddresses": [
        "",
        "SMTP:",
        "smtp:"
      ],
      "renewedDateTime": "2018-09-07T16:23:37Z",
      "onPremisesProvisioningErrors": []
    },
    {
      "id": "",
      "deletedDateTime": null,
      "classification": null,
      "createdDateTime": "2019-01-11T17:34:30Z",
      "**creationOptions**": [
        "Team",
        "ExchangeProvisioningFlags"
      ],
      "description": "Discuss",
      "displayName": "I&O",
      "groupTypes": [
        "Unified"
      ],
      "isAssignableToRole": null,
      "mail": "",
      "preferredDataLocation": null,
      "proxyAddresses": [
        "SPO",
        "SMTP:",
        "smtp:"
      ],
      "renewedDateTime": "2019-01-11T17:34:30Z",
      "resourceBehaviorOptions": [],
      "resourceProvisioningOptions": [
        "Team"
      ],
      "onPremisesProvisioningErrors": []
    },
    {
      "id": "",
      "deletedDateTime": null,
      "classification": null,
      "createdDateTime": "2018-12-10T21:14:47Z",
      "**creationOptions**": [
        "YammerProvisioning"
      ],
      "description": "",
      "displayName": "",
      "groupTypes": [
        "Unified"
      ],
      "isAssignableToRole": null,
      "mailEnabled": true,
      "onPremisesDomainName": null,
      "onPremisesLastSyncDateTime": null,
      "onPremisesNetBiosName": null,
      "onPremisesSamAccountName": null,
      "onPremisesSecurityIdentifier": null,
      "onPremisesSyncEnabled": null,
      "preferredDataLocation": null,
      "proxyAddresses": [],
      "renewedDateTime": "2018-12-10T21:14:47Z",
      "resourceBehaviorOptions": [
        "CalendarMemberReadOnly"
      ],
      "resourceProvisioningOptions": [],
      "onPremisesProvisioningErrors": []
    }
  ]
}

如您所见,json 中的每个对象都有 'creationOptions',这意味着一个组可能会在该字段中填充一些值。我只对 return creationOptions = YammerProvisioning 的那些组感兴趣。

但是 $filter 只能应用于字符串而不是数组,所以我不确定该查询如何正确。我试过,但是,它的过滤器子句无效。

https://graph.microsoft.com/v1.0/groups?$filter=equals(creationOptions,'YammerProvisioning')

我尝试的另一种方法如下,它给出了相同的数组。

https://graph.microsoft.com/v1.0/groups?$filter=startswith(creationOptions,['YammerProvisioning'])

我的目标是简单获取所有具有 creationOptions 的组 'YammerProvisioning'

感谢帮助或示例 :) 谢谢

此语法应该有效,但在 v1.0 中可能不受支持。 ?$filter=creationOptions/any(r:r+eq+'YammerProvisioning')

Beta 端点似乎没有 creationOptions,但您可以尝试反对 resourceBehaviorOptions。

https://www.techmikael.com/2017/11/how-to-list-all-office-365-groups-which.html?m=1

虽然不是所有租户都可靠("However, not all Yammer-enabled groups are reported by looking at the ResourceBehaviorOptions. It seems like Yammer communities that already used Office 365 Groups before the migration had the property configured while communities converted to Office 365 Groups during the migration did not. Perhaps some background process will update the property for the other groups over time.") https://office365itpros.com/2020/04/13/moving-yammer-networks-native-mode-microsoft-365/