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

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

问题描述

我正在尝试通过 microsoft graph 接收有关日历事件的推送通知

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

我的订阅有这些选项.

   {
   "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!! =).

推荐答案

我也有同样的问题.在办公室日历中创建新事件时,我每次都会收到一个带有 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 并将其存储到数组或数据库中,每当您收到通知时,请记住验证您是否已经在数组或数据库中拥有该事件的 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/订阅,向我的 notificationUrl 发送多个帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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