使用Microsoft Graph change notifications,您可以在所有组上使用create a subscription(又名webhook)(即update 订阅groups 资源)。这将包括任何群组成员更改的通知。
创建订阅:
POST https://graph.microsoft.com/v1.0/subscriptions
{
"changeType": "updated",
"notificationUrl": "https://www.example.com/notifications",
"resource": "groups",
"expirationDateTime": "2019-04-06T14:55:47.082Z"
}
在此示例通知中,id "4300f326-4062-4daf-9b91-018f82e87361" 的对象已添加到id4f747e07-50c1-4797-8eba-a2bb7104bfc4 的组中:
{
"value": [
{
"changeType": "updated",
"clientState": null,
"resource": "Groups/4f747e07-50c1-4797-8eba-a2bb7104bfc4",
"resourceData": {
"@odata.type": "#Microsoft.Graph.Group",
"@odata.id": "Groups/4f747e07-50c1-4797-8eba-a2bb7104bfc4",
"id": "4f747e07-50c1-4797-8eba-a2bb7104bfc4",
"organizationId": "1c411c5e-78cc-4e89-af5e-169408a540b8",
"sequenceNumber": 636899867048350977,
"members@delta": [
{
"id": "4300f326-4062-4daf-9b91-018f82e87361"
}
]
},
"subscriptionExpirationDateTime": "2019-04-06T14:55:47.082+00:00",
"subscriptionId": "448ed5dc-73e9-4c5a-9d4f-94bd7c5dd762",
"tenantId": "1c411c5e-78cc-4e89-af5e-169408a540b8"
}
]
}
这里,同一个用户已从组中删除(注意 members@delta 中项目中的 @removed 属性):
{
"value": [
{
"changeType": "updated",
"clientState": null,
"resource": "Groups/4f747e07-50c1-4797-8eba-a2bb7104bfc4",
"resourceData": {
"@odata.type": "#Microsoft.Graph.Group",
"@odata.id": "Groups/4f747e07-50c1-4797-8eba-a2bb7104bfc4",
"id": "4f747e07-50c1-4797-8eba-a2bb7104bfc4",
"organizationId": "1c411c5e-78cc-4e89-af5e-169408a540b8",
"sequenceNumber": 636899869819085879,
"members@delta": [
{
"id": "4300f326-4062-4daf-9b91-018f82e87361",
"@removed": "deleted"
}
]
},
"subscriptionExpirationDateTime": "2019-04-06T14:55:47.082+00:00",
"subscriptionId": "448ed5dc-73e9-4c5a-9d4f-94bd7c5dd762",
"tenantId": "1c411c5e-78cc-4e89-af5e-169408a540b8"
}
]
}