Microsoft Graph Webhook/Subscription,将多个帖子发送到我的notificationUrl [英] Microsoft Graph Webhook/Subscription, getting multiple post to my notificationUrl

查看:52
本文介绍了Microsoft Graph Webhook/Subscription,将多个帖子发送到我的notificationUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Microsoft图形接收有关日历事件的推送通知

Im trying to receive push notification on calendar events through microsoft graph

notificationURL指向在NodeJS上运行的Web服务

the notificationURL points to webservice which is running on NodeJS

我进行的订阅有这些选项.

subscription I have made has these options.

   {
   "changeType": "created,updated,deleted",
   "notificationUrl": "myurl",
   "resource": "users/userid/events?$filter=sensitivity%20eq%20%27Normal%27",
   "expirationDateTime":"2016-11-05T18:23:45.9356913Z",
   "clientState": "customclientstate"
}

无论何时更改单个事件,我都会收到来自订阅的多个POST调用(2〜4个)(它们都具有相同的主体).

however im getting multiple POST calls(2~4) coming from subscription(all of them having identical body) whenever a single event is changed.

只有一个订阅处于活动状态,一个日历,并且我正在用状态代码204响应请求,而没有任何内容(经过邮递员测试).

there is only one subscription active, a single calendar, and i am responding to the request with status code 204 without any content(tested with postman).

这是一个大问题,因为无论何时收到请求,我都会立即更新数据库.

its a huge problem since im updating DB whenever the request comes in.

有人遇到这个问题吗?香港专业教育学院一直到处寻找没有任何结果.

has anyone run into this problem? ive been looking all over without any results.

任何输入将不胜感激! =).

any input would be greatly appreciated!! =).

推荐答案

我遇到了同样的问题.在Office日历中创建新事件时,每次都会通过ChangeType: Created收到一个通知,同时通过ChangeType: Updated会收到三个通知.当我在办公室取消活动时,总是收到3 x更新的通知,最后是1 x ChangeType: Deleted.

I have this same issue. When creating new event in office calendar I'll get everytime one notification with ChangeType: Created and at the same time three notifications with ChangeType: Updated. When I'm cancelling event in office I get always 3 x Updated notifications and finally 1 x ChangeType: Deleted.

您可以在这里使用ChangeKey验证.每当您从办公室收到新通知时,都必须通过API请求该事件,对吗?

What you can do here is to use ChangeKey validation. Everytime you get new notification from office you have to request that event from API, right?

获取该事件后,您可以检查event.ChangeKey属性是否已更改.

Once you fetched that event you can check if event.ChangeKey property has changed.

这与网站中的etag相同.如果内容更改,则etag哈希也会更改.

It's same thing as etag in websites. If content changes, etag hash changes.

因此,当您收到Created通知时,请获取该事件的ChangeKey并将其存储到数组或db中,每当收到通知时,请记住验证是否已在数组或db中包含该事件的ID,以及ChangeKey是否已更改.如果ChangeKey与上次相同,则无需在db中更新该事件.

So when you get Created notification, take that event's ChangeKey and store it to array or db and whenever you get notification remember to validate if you have that event's ID already in array or db and also if ChangeKey has changed. If ChangeKey is same as last time, you won't need to update that event in db.

这也适用于重复发生的事件,即使一次事件发生了更改,SeriesMaster事件的ChangeKey也将发生变化.

This also works with recurring events, if even one occurrence has changed SeriesMaster event's ChangeKey also changes.

这篇关于Microsoft Graph Webhook/Subscription,将多个帖子发送到我的notificationUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆