创建事件不确认传入的时区

hp.*_*hp. 3 outlook-restapi microsoft-graph-api

我正在使用 Microsoft Graph 创建一个event. 一切正常,除了它总是以 UTC 创建事件。我正在遵循文档中的示例,但仍然没有运气。

这是帖子的正文:

{
    "subject": "My event",
    "start": {
        "dateTime": "2017-11-03T04:14:31.883Z",
        "timeZone": "Eastern Standard Time"
    },
    "end": {
        "dateTime": "2017-11-10T05:14:31.883Z",
        "timeZone": "Eastern Standard Time"
    }
}
Run Code Online (Sandbox Code Playgroud)

这是回应:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('...')/events/$entity",
    "@odata.etag": "W/\"1OZnj8JcDU6yRK1K4rYSNQABJ3X/lw==\"",
    "id": "...",
    "createdDateTime": "2017-11-03T04:15:13.7075368Z",
    "lastModifiedDateTime": "2017-11-03T04:15:13.7231636Z",
    "changeKey": "1OZnj8JcDU6yRK1K4rYSNQABJ3X/lw==",
    "categories": [],
    "originalStartTimeZone": "UTC",
    "originalEndTimeZone": "UTC",
    "iCalUId": "...",
    "reminderMinutesBeforeStart": 15,
    "isReminderOn": true,
    "hasAttachments": false,
    "subject": "My event",
    "bodyPreview": "",
    "importance": "normal",
    "sensitivity": "normal",
    "isAllDay": false,
    "isCancelled": false,
    "isOrganizer": true,
    "responseRequested": true,
    "seriesMasterId": null,
    "showAs": "busy",
    "type": "singleInstance",
    "webLink": "...",
    "onlineMeetingUrl": null,
    "responseStatus": {
        "response": "organizer",
        "time": "0001-01-01T00:00:00Z"
    },
    "body": {
        "contentType": "text",
        "content": ""
    },
    "start": {
        "dateTime": "2017-11-03T04:14:31.8830000",
        "timeZone": "UTC"
    },
    "end": {
        "dateTime": "2017-11-10T05:14:31.8830000",
        "timeZone": "UTC"
    },
}
Run Code Online (Sandbox Code Playgroud)

Vad*_*hev 5

由于startend属性代表dateTimeTimeZone类型,并且DateTime属性期望以yyyy-mm-ddThh:mm[:ss[.fffffff]]格式指定值(有关更多详细信息,请参阅Edm.DateTime 类型描述)。

在您的示例中,Z需要省略,2017-11-10T05:14:31.883Z因为'Z' 是零 UTC 偏移量的区域指示符timeZone,这就是属性被忽略的原因。

例如:

{
  "subject": "My event",
  "start": {
    "dateTime": "2017-11-03T04:14:31.8830000",
    "timeZone": "Eastern Standard Time"
  },
  "end": {
    "dateTime": "2017-11-10T05:14:31.8830000",
    "timeZone": "Eastern Standard Time"
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 但是,当发送包含不明确数据的请求时,如果收到错误 400,那就太好了。我相信没有描述这种行为(在“Z”的情况下忽略时区)。 (3认同)