我的REST API规范与Outlook API通信

问题描述 投票:0回答:2

我尝试使用Outlook REST API从outlook获取事件列表。 根据微软的文件首先;我需要订阅outlook

终点是:https://outlook.office.com/api/v2.0/me/subscriptions 它需要NotificationURL参数才能在事件发生更改时发送通知。 我应该实现一个REST API(用于NotificationURL)来传递outlook作为参数,但我找不到任何文档。 什么参数应该得到我的REST端点或它的类型(post,get,put等...) 我感谢您的帮助 谢谢!

我的REST API规范与Outlook API通信

outlook office365 office365api outlook-restapi
2个回答
0
投票

如果您希望获得事件列表,则根本不需要使用订阅。只需使用here描述的程序。


0
投票

微软已经推出了针对Outlook事件的推送通知api aka webhook。为此,您需要首先注册(创建资源订阅)webhook。请查看以下代码段,该代码段允许在通知网址上创建或更新任何事件时发送通知。 doc这里https://docs.microsoft.com/en-us/graph/webhooks#notification-endpoint-validation

POST https://graph.microsoft.com/v1.0/subscriptions Content-type: application/json { "changeType": "created,updated", "notificationUrl": "<YOUR-notification api endpoint>/api/notify", "resource": "me/events", "expirationDateTime":"2019-03-3T18:23:45.9356913Z", "clientState": "myOutlookEvents" }

您可以使用clientState来验证来自MS Graph的端点请求。

MS将以下面的格式发布数据

{
  "value": [
    {
      "subscriptionId":"<subscription_guid>",
      "subscriptionExpirationDateTime":2019-03-3T18:23:45.9356913Z",
      "clientState": "myOutlookEvents",
      "changeType":"created",
      "resource":"users/{user_guid}@<tenant_guid>/event/{long_id_string}",
      "resourceData":
      {
        "@odata.type":"#Microsoft.Graph.Event",
        "@odata.id":"Users/{user_guid}@<tenant_guid>/event/{long_id_string}",
        "@odata.etag":"W/\"CQAAABYAAADkrWGo7bouTKlsgTZMr9KwAAAUWRHf\"",
        "id":"<long_id_string>"
      }
    }
  ]
}

在此之后,您需要从图api收到的id中获取事件

© www.soinside.com 2019 - 2024. All rights reserved.