无法使用Graph API创建从Google导入的事件



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

使用Graph Explorer我看到导入事件中的originalStartTimeZoneoriginalEndTimeZonetzone://Microsoft/CustomrecurrenceTimeZone是一个空字符串。

{
  "@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">rn<!-- converted from text -->rn<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style></head>rn<body>rn<font size="2"><span style="font-size:11pt;"><div class="PlainText">&nbsp;</div></span></font>rn</body>rn</html>rn"
  },
  "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"
    }
  }
}

此外,当我使用此event对象作为创建事件API的请求主体时,它会返回此错误:

{
  "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的限制?

答案与我向您的问题提供的答案相同,无法通过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">rn<!-- converted from text -->rn<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style></head>rn<body>rn<font size="2"><span style="font-size:11pt;"><div class="PlainText">&nbsp;</div></span></font>rn</body>rn</html>rn"
  },
  "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"
    }
  }
}

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

最新更新