根据document,我尝试使用Graph API在我的日历上创建一整天重复事件,但服务器总是响应400:TimeZoneNotSupportedException。
我的请求有什么不对吗?
这是我的请求和服务器响应。
POST / me / calendars / $ {one_of_my_calendar_id} / events
请求机构:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('6cb879ad-1d01-4aed-bcc5-763e3f51c535')/events/$entity",
"@odata.etag": "W/\"BfXylo4WykyAenTZICXL5AABk4B1gA==\"",
"id": "AAMkADVmMzE2MjY0LTZkOGYtNGI4MS1iNWMxLTljYzg3MWY5MWQxMQBGAAAAAABZMfR36TVMQ6yunaqZPvVRBwAF9fKWjhbKTIB6dNkgJcvkAACB0WDVAAAF9fKWjhbKTIB6dNkgJcvkAAGTapeDAAA=",
"createdDateTime": "2019-03-07T10:25:29.5732546Z",
"lastModifiedDateTime": "2019-03-07T10:25:29.6573241Z",
"changeKey": "BfXylo4WykyAenTZICXL5AABk4B1gA==",
"categories": [],
"originalStartTimeZone": "UTC",
"originalEndTimeZone": "UTC",
"iCalUId": "040000008200E00074C5B7101A82E00800000000FB7128DC464BD4010000000000000000100000006176917542798940B4FDBBFBA5B474A6",
"reminderMinutesBeforeStart": 0,
"isReminderOn": false,
"hasAttachments": false,
"subject": "Repeat-",
"bodyPreview": "",
"importance": "normal",
"sensitivity": "normal",
"isAllDay": true,
"isCancelled": false,
"isOrganizer": true,
"responseRequested": false,
"seriesMasterId": null,
"showAs": "free",
"type": "seriesMaster",
"webLink": "https://outlook.office365.com/owa/?itemid=AAMkADVmMzE2MjY0LTZkOGYtNGI4MS1iNWMxLTljYzg3MWY5MWQxMQBGAAAAAABZMfR36TVMQ6yunaqZPvVRBwAF9fKWjhbKTIB6dNkgJcvkAACB0WDVAAAF9fKWjhbKTIB6dNkgJcvkAAGTapeDAAA%3D&exvsurl=1&path=/calendar/item",
"onlineMeetingUrl": null,
"responseStatus": {
"response": "organizer",
"time": "0001-01-01T00:00:00Z"
},
"body": {
"contentType": "html",
"content": "<html><head><meta name=\"Generator\" content=\"Microsoft Exchange Server\">\r\n<!-- converted from text
-->\r\n<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; }
--></style></head>\r\n<body>\r\n<font size=\"2\"><span style=\"font-size:11pt;\"><div class=\"PlainText\"> </div></span></font>\r\n</body>\r\n</html>\r\n"
},
"start": {
"dateTime": "2018-09-25T00:00:00.0000000",
"timeZone": "UTC"
},
"end": {
"dateTime": "2018-09-26T00:00:00.0000000",
"timeZone": "UTC"
},
"location": {
"displayName": "",
"locationType": "default",
"uniqueIdType": "unknown",
"address": {},
"coordinates": {}
},
"locations": [],
"recurrence": {
"pattern": {
"type": "weekly",
"interval": 1,
"month": 0,
"dayOfMonth": 0,
"daysOfWeek": [
"tuesday"
],
"firstDayOfWeek": "monday",
"index": "first"
},
"range": {
"type": "endDate",
"startDate": "2018-09-25",
"endDate": "2019-03-12",
"recurrenceTimeZone": "",
"numberOfOccurrences": 0
}
},
"attendees": [],
"organizer": {
"emailAddress": {
"name": "MYNAME",
"address": "[email protected]"
}
} }
服务器响应:http代码:400
{
"error": {
"code": "TimeZoneNotSupportedException",
"message": "A valid TimeZone value must be specified. The following TimeZone value is not supported: ''.",
"innerError": {
"request-id": "4833ea1a-3371-4d3e-b28e-193fec18f723",
"date": "2019-03-07T11:01:36"
}
}
}
您正在发布整个对象,包括几个只读属性。这将导致某种失败。
使用Microsoft Graph(实际上大多数是任何REST API)时,您应该只提交要设置的属性:
{
"subject": "Repeat-",
"isAllDay": true,
"isReminderOn": false,
"showAs": "free",
"body": {
"contentType": "html",
"content": "<html><head><meta name=\"Generator\" content=\"Microsoft Exchange Server\">\r\n<!-- converted from text\r\n<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; }</style></head>\r\n<body>\r\n<font size=\"2\"><span style=\"font-size:11pt;\"><div class=\"PlainText\"> </div></span></font>\r\n</body>\r\n</html>\r\n"
},
"recurrence": {
"pattern": {
"type": "weekly",
"interval": 1,
"daysOfWeek": ["Tuesday"]
},
"range": {
"type": "endDate",
"startDate": "2018-09-25",
"endDate": "2019-03-12"
}
}
}
从重复/范围值中删除'recurrenceTimeZone'后,服务器响应200 OK,并成功创建新事件。
似乎recurrenceTimeZone不应该是无效的时区值。