无法通过 Graph API 创建全天重复 [英] Can't create a all-day repeated via Graph API
问题描述
根据 文档,我尝试使用 Graph API 在我的日历上创建一个全天重复的事件,但服务器总是响应 400: TimeZoneNotSupportedException.
According to the document, I try to use Graph API to create a all-day repeated event on my calendar, but the server always responses 400: TimeZoneNotSupportedException.
我的请求有什么问题吗?
Is there any wrong in my request?
这是我的请求和服务器响应.
Here is my request and server response.
POST/me/calendars/${one_of_my_calendar_id}/events
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": "MYNAME@MYMAIL.com"
}
} }
服务器响应:http代码:400
Server response: http code: 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"
}
}
}
推荐答案
您要发布整个对象,包括几个只读属性.这总是会导致某种失败.
You're posting the entire object, including several read-only properties. This will always result in a failure of some kind.
使用 Microsoft Graph 时(实际上是大多数 REST API),您应该只提交您想要设置的属性:
When working with Microsoft Graph (most any REST API actually), you should only submit the properties you want to set:
{
"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"
}
}
}
这篇关于无法通过 Graph API 创建全天重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!