如何从我收到的电子邮件中了解事件ID?

时间:2017-09-07 00:10:38

标签: microsoft-graph office365api

我正在使用Microsoft Graph实现一项功能,可以接受其他人通过电子邮件发送给我的会议(活动)。但是,要做到这一点,我首先需要知道事件Id。我在message doc

中找不到任何有用的信息

这是我收到的有关活动信息的邮件。哪个值是事件ID?感谢

{
  "@odata.type": "#microsoft.graph.eventMessageRequest",
  "@odata.etag": "W/\"CwAAABYAAACpTc/InBsuTYwTUBb+VIb5AABxZpE6\"",
  "id": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk-iwQZRbXMgkfKtmYhBwCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAACpTc-InBsuTYwTUBb_VIb4AABx3MA8AAA=",
  "createdDateTime": "2017-09-06T22:03:44Z",
  "lastModifiedDateTime": "2017-09-06T23:54:42Z",
  "changeKey": "CwAAABYAAACpTc/InBsuTYwTUBb+VIb4AABxZpE6",
  "categories": [],
  "receivedDateTime": "2017-09-06T22:03:46Z",
  "sentDateTime": "2017-09-06T22:02:14Z",
  "hasAttachments": true,
  "internetMessageId": "<CY1PR00MB0185E9373E8D4FF8A97C5675DF970@CY2PR00MB0185.namprd00.prod.outlook.com>",
  "subject": "Hello",
  "bodyPreview": "preview of the email",
  "importance": "normal",
  "parentFolderId": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgAuAAAAAACUbnk-iwQZRbXMgkfKtmYhAQCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAAA=",
  "conversationId": "AAQkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgAQAHwtGwSJ6Egxl56psayEpP8=",
  "conversationIndex": "AdMnW7xOfC0bBInoSDGXnqmxrISk/wAAA0nA",
  "isDeliveryReceiptRequested": null,
  "isReadReceiptRequested": false,
  "isRead": true,
  "isDraft": false,
  "webLink": "https://outlook.office365.com/owa/?ItemID=AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk%2FiwQZRbXMgkfKtaYhBwCpTc%2FInBsuTYwTUBb%2BVIb4AAAAAAEMAACpTc%2FInBsuTYwTUBb%2BVIb4AABxMs5PAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
  "inferenceClassification": "focused",
  "unsubscribeData": [],
  "unsubscribeEnabled": false,
  "meetingMessageType": "meetingRequest",
  "type": "singleInstance",
  "isOutOfDate": false,
  "isAllDay": false,
  "isDelegated": false,
  "responseRequested": true,
  "body": {
    "contentType": "html",
    "content": "<html>a long email</html>\r\n"
  },
  "sender": {
    "emailAddress": {
      "name": "Rose",
      "address": "rose@example.com"
    }
  },
  "from": {
    "emailAddress": {
      "name": "Rose",
      "address": "rose@example.com"
    }
  },
  "toRecipients": [
    {
      "emailAddress": {
        "name": "Jack",
        "address": "jack@example.com"
      }
    }
  ],
  "ccRecipients": [],
  "bccRecipients": [],
  "replyTo": [],
  "mentionsPreview": null,
  "flag": {
    "flagStatus": "notFlagged"
  },
  "startDateTime": {
    "dateTime": "2017-09-11T18:00:00.0000000",
    "timeZone": "UTC"
  },
  "endDateTime": {
    "dateTime": "2017-09-11T19:00:00.0000000",
    "timeZone": "UTC"
  },
  "location": {
    "displayName": "TBD",
    "locationType": "default",
    "uniqueIdType": "unknown"
  },
  "recurrence": null,
  "previousLocation": null,
  "previousStartDateTime": null,
  "previousEndDateTime": null
}

更新:

我尝试GET https://graph.microsoft.com/v1.0/me/messages/aVeryLongMailId/event,它返回 400 Bad Request

{
    "error": {
        "code": "BadRequest",
        "message": "Unsupported segment type. ODataQuery: users/576552d5-3bc0-42a6-a53d-bfceb405db23/messages/AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk-iwQZRbXMgkfKtmYhBwCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAACpTc-InBsuTYwTUBb_VIb4AAB2sQVPAAA=/event",
        "innerError": {
            "request-id": "f7d265de-85cc-41a0-bea9-2282f76c29f5",
            "date": "2017-09-15T23:45:40"
        }
    }
}

1 个答案:

答案 0 :(得分:2)

这不是消息,而是eventMessage。你应该有一个/事件关系,让你得到事件。所以格式为:

GET /me/messages/{meeting-request-id}?$expand=microsoft.graph.eventMessage/event

其中{meeting-request-id}是事件消息的ID。

此处的$expand参数会将会议请求转换为正确的类型(microsoft.graph.eventMessage)以访问event属性,然后在响应中展开它。