我正在使用 Microsoft 的 Graph API 和我的 Node.js 应用程序创建一个 Outlook 日历事件。按照此文档/示例链接:https ://docs.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/calendar-rest-operations#CreateEvents
我的代码:
var options = {
method: 'POST',
url: 'https://graph.microsoft.com/v1.0/me/calendar/events',
headers: {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/json'
},
body: {
"subject": "Node.js outlook test",
"body": {
"contentType": "HTML",
"content": "Test event created from node.js"
},
"start": {
"dateTime": "2019-03-25T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2019-03-25T14:00:00",
"timeZone": "Pacific Standard Time"
},
"isAllDay": false,
"location": {
"displayName": null
},
"attendees": [{
"emailAddress": {
"address": "my-other-email@gmail.com",
"name": "Adele Vance"
},
"type": "required"
}]
},
json: true
};
request(options, function (err, response, body) {
if (err) throw new Error(err);
res.send(body);
});
该事件是在 Outlook 日历中创建的,但没有与该事件关联的与会者。
创建事件后,我收到以下响应
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('my_hotmail_email%40hotmail.com')/calendar/events/$entity",
"@odata.etag": "W/\"69zWaBpmuEqq9NMFBSWV6QACU8X/gQ==\"",
"id": "AQMkADAwATYwMAItYzA3My1mNzUxLTAwAi0wMAoARgAAAwh1Hv4SptVMlm3BaW7y4g0HAOvc1mgaZrhKqvTTBQUAJZXpAAACAQ0AAADr3NZoGma4Sqr00wUFACWV6QACU7Qp1gAAAA==",
"createdDateTime": "2019-05-02T09:12:12.0349227Z",
"lastModifiedDateTime": "2019-05-02T09:12:12.0789547Z",
"changeKey": "69zWaBpmuEqq9NMFBSWV6QACU8X/gQ==",
"categories": [],
"originalStartTimeZone": "Pacific Standard Time",
"originalEndTimeZone": "Pacific Standard Time",
"iCalUId": "040000008200E00074C5B7101A82E0080000000077C77520C700D5010000000000000000100000001CB042E1D2C57341BA3D3799F9853B63",
"reminderMinutesBeforeStart": 15,
"isReminderOn": true,
"hasAttachments": false,
"subject": "Node.js outlook test",
"bodyPreview": "Test event created from node.js",
"importance": "normal",
"sensitivity": "normal",
"isAllDay": false,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": true,
"seriesMasterId": null,
"showAs": "busy",
"type": "singleInstance",
"webLink": "https://outlook.live.com/owa/?itemid=AQMkADAwATYwMAItYzA3My1mNzUxLTAwAi0wMAoARgAAAwh1Hv4SptVMlm3BaW7y4g0HAOvc1mgaZrhKqvTTBQUAJZXpAAACAQ0AAADr3NZoGma4Sqr00wUFACWV6QACU7Qp1gAAAA%3D%3D&exvsurl=1&path=/calendar/item",
"onlineMeetingUrl": null,
"recurrence": null,
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"body": {
"contentType": "html",
"content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nDoes mid month work for you?\r\n</body>\r\n</html>\r\n"
},
"start": {
"dateTime": "2019-03-25T12:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2019-03-25T14:00:00.0000000",
"timeZone": "Pacific Standard Time"
},
"attendees": [
{
"type": "required",
"status": {
"response": "none",
"time": "0001-01-01T00:00:00Z"
},
"emailAddress": {
"name": "My Name",
"address": "my_hotmail_email@hotmail.com"
}
}
],
"organizer": {
"emailAddress": {
"name": "My Name",
"address": "my_hotmail_email@hotmail.com"
}
}
}
正如您在参加者数组中看到的那样,它提供了我自己的 hotmail/outlook 帐户,但没有提供请求中包含的 gmail 帐户。
我的 gmail 帐户也没有收到任何日历邀请。知道可能出了什么问题吗?