通过Rest Api的Microsoft Graph Api Webhook订阅不再起作用

问题描述:

我有一个正在运行的应用程序,可以从MS-Graph Api接收电子邮件Webhook事件. 我注意到我找不到使用subscriptionId的订阅,却收到404错误.我也无法使用ID删除订阅.

I have a working application that receive email webhook events from MS-Graph Api. I noticed that I could not find the subscription back using the subscriptionId, I get a 404 error.I also cannot delete the subscription using the id.

我进行了进一步调查,发现我不能再创建新的订阅了: 在Azure AD中注册的应用程序是服务应用程序(守护程序)

I investigated further and noticed that I cannot create new subscriptions anymore: The Application registered in Azure AD is a service-application (daemon)

我的应用程序会自动续订订阅,并且每次更新都会收到202响应,但不知何故订阅会丢失.

My application auto renews the subscriptions and every time it did that I get a 202 response, but somehow the the subscription gets lost.

请求:

POST: https://graph.microsoft.com/beta/subscriptions

{ "changeType": "created,updated,deleted", "notificationUrl": "https://myapi.azurewebsites.net/GraphWebhook/Inbox", "resource": "Users/myemail@company.nl/mailFolders('inbox')/messages", "expirationDateTime":"2016-10-25T20:23:45.9356913Z", "clientState": "subscription-identifier" }

{ "changeType": "created,updated,deleted", "notificationUrl": "https://myapi.azurewebsites.net/GraphWebhook/Inbox", "resource": "Users/myemail@company.nl/mailFolders('inbox')/messages", "expirationDateTime":"2016-10-25T20:23:45.9356913Z", "clientState": "subscription-identifier" }

响应:

"error": {
"code": "ExtensionError",
"message": "Operation: Create; Exception: [Status Code: NotFound; Reason: Not Found]",
"innerError": {
  "request-id": "681ac550-be6f-4882-9b6b-e089c36ad38e",
  "date": "2016-10-25T10:13:25"
}

有人有什么想法吗?

更新:立即重新工作.

UPDATE: Working now again out of the blue.

该API支持用户ID和用户电子邮件地址作为资源路径的一部分,并且进行更改.要检查是API问题还是资源问题,您可以尝试使用图形浏览器访问资源:

The API supports both user id and user email address as part of resource path and it DOES NOT change. To check whether it is API issue or resource issue, you could try to access your resource using graph explorer:

获取 https://graph.microsoft.com/beta/users/myemail@company.nl/mailFolders ('inbox')/messages

GET https://graph.microsoft.com/beta/users/myemail@company.nl/mailFolders('inbox')/messages

关于您在创建订阅时看到的错误,它看起来像是与此相关的Exchange问​​题.

Regarding the error you saw when creating subscription, it looks like an Exchange issue related to this.

希望这会有所帮助.