-1

我通过在 Google 日历中创建的ics 文件将一些事件导入我的 Outlook日历。导入成功,但我发现这些事件对象与我通过 Outlook UI 创建的其他事件不同。

使用 Graph Explorer 我看到originalStartTimeZoneoriginalEndTimeZone在导入的事件中是tzone://Microsoft/Custom并且recurrenceTimeZone是一个空字符串。

{
  "@odata.etag": "W/\"jQw3WvygBke/Eeuel/y+PAACnR0HFQ==\"",
  "id": "AAMkADU2MzY5ODJlLWI2YjgtNDM5YS1iMWQzLTkxNWFlOTk3MjA3MABGAAAAAAAZitkJ2449ToBFAe4BGzZIBwCNDDda-KAGR78R656X-L48AAKczwuSAACNDDda-KAGR78R656X-L48AAKcz0NjAAA=",
  "createdDateTime": "2019-03-11T12:58:33.1040062Z",
  "lastModifiedDateTime": "2019-03-11T12:58:33.2340999Z",
  "changeKey": "jQw3WvygBke/Eeuel/y+PAACnR0HFQ==",
  "categories": [],
  "originalStartTimeZone": "tzone://Microsoft/Custom",
  "originalEndTimeZone": "tzone://Microsoft/Custom",
  "iCalUId": "040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000320000007643616C2D55696401000000336A6C61316A6773666C6B766D70666F766D6D7365686439647240676F6F676C652E636F6D00",
  "reminderMinutesBeforeStart": 0,
  "isReminderOn": false,
  "hasAttachments": false,
  "subject": "Every Tue.",
  "bodyPreview": "",
  "importance": "normal",
  "sensitivity": "normal",
  "isAllDay": false,
  "isCancelled": false,
  "isOrganizer": true,
  "responseRequested": false,
  "seriesMasterId": null,
  "showAs": "busy",
  "type": "seriesMaster",
  "webLink": "https://outlook.office365.com/owa/?itemid=AAMkADU2MzY5ODJlLWI2YjgtNDM5YS1iMWQzLTkxNWFlOTk3MjA3MABGAAAAAAAZitkJ2449ToBFAe4BGzZIBwCNDDda%2FKAGR78R656X%2FL48AAKczwuSAACNDDda%2FKAGR78R656X%2FL48AAKcz0NjAAA%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\">&nbsp;</div></span></font>\r\n</body>\r\n</html>\r\n"
  },
  "start": {
    "dateTime": "2018-08-13T22:00:00.0000000",
    "timeZone": "UTC"
  },
  "end": {
    "dateTime": "2018-08-14T00: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-08-14",
      "endDate": "2018-09-18",
      "recurrenceTimeZone": "",
      "numberOfOccurrences": 0
    }
  },
  "attendees": [],
  "organizer": {
    "emailAddress": {
      "name": "my@gsuite.com",
      "address": "my@gsuite.com"
    }
  }
}

此外,当我将此对象用作Create Event APIevent的请求主体时,它会返回此错误:

{
  "error": {
    "code": "TimeZoneNotSupportedException",
    "message": "A valid TimeZone value must be specified. The following TimeZone value is not supported: ''.",
    "innerError": {
      "request-id": "69f1a5de-1dbe-4caa-a996-15dc9190380c",
      "date": "2019-03-13T13:37:24"
    }
  }
}

这是导入.ics文件的错误还是 API 的限制?

4

1 回答 1

1

答案与我对您的问题Can't create a all-day repeat via Graph API提供的相同:

您正在发布整个对象,包括几个只读属性。这总是会导致某种失败。

使用 Microsoft Graph(实际上是大多数 REST API)时,您应该只提交您想要设置的属性。

对于上述事件,您将发送如下内容:

POST https://graph.microsoft.com/v1.0/me/events
{
  "isReminderOn": false,
  "subject": "Every Tue.",
  "importance": "normal",
  "sensitivity": "normal",
  "showAs": "busy",
  "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\">&nbsp;</div></span></font>\r\n</body>\r\n</html>\r\n"
  },
  "start": {
    "dateTime": "2018-08-13T22:00:00.0000000",
    "timeZone": "UTC"
  },
  "end": {
    "dateTime": "2018-08-14T00:00:00.0000000",
    "timeZone": "UTC"
  },
  "recurrence": {
    "pattern": {
      "type": "weekly",
      "interval": 1,
      "daysOfWeek": ["Tuesday"]
    },
    "range": {
      "type": "endDate",
      "startDate": "2018-08-14",
      "endDate": "2018-09-18"
    }
  }
}

为了将来参考,文档中还有一个已发布的支持时区列表。

于 2019-03-15T16:05:20.007 回答