6
votes

I am trying to export some events to a calendar in Office 365 through their REST API, https://msdn.microsoft.com/office/office365/APi/calendar-rest-operations#EventoperationsCreateevents.

I set the IsAllDay to true, and set the start and end to midnight in UTC.

The payload looks like this:

{
  "Body": {
    "Content": "Agenda",
    "ContentType": "HTML"
  },
  "End": "2015-02-01T00:00:00Z",
  "ShowAs": "Busy",
  "Start": "2015-01-30T00:00:00Z",
  "ChangeKey": "X2+akAeClEa0OJ8r6nC5QgABW30vaQ==",
  "Location": {
    "DisplayName": "Vesterbrogade"
  },
  "Subject": "Updated title",
  "IsAllDay": true
}

That looks fine, and if I GET the event again, the payload comes back as set. However when I go to outlook.office365.com the event now spans 2 days, instead of 1 as intended. The duration however appears as 1 day. Unclicking the "all day" in Outlook reveals the problem. Since I am in Central European Time, I'm one hour ahead of UTC. The start shows as 2015-01-30 01:00 and the end as 2015-02-01 00:59. So underneath the covers it doesn't seem to be stored as an all day event in my timezone.

When you use f.ex. EWS, you normally set the timezone of the meeting, however that doesn't appear to be possible.

I have tried to give the start and end with timezone information, but I get a 400 telling me it has to be supplied in UTC. So as far as I can tell there is nothing I can, expect hope that Microsoft fixes this. Or am I missing something?

EDIT: The event actually appears correctly in Outlook for Mac, so perhaps this is only a problem in the OWA at outlook.office365.com.

1

1 Answers

5
votes

The API now supports time zones. What you would want to do here is not specify your Start and End as UTC (indicated by the 'Z' prefix on the end), but instead specify it in your time zone. You would then set the StartTimeZone and EndTimeZone values to "Central European Time". So something like this:

{
  "Body": {
    "Content": "Agenda",
    "ContentType": "HTML"
  },
  "Start": "2015-01-30T00:00:00+01:00",
  "End": "2015-02-01T00:00:00+01:00",
  "ShowAs": "Busy",
  "Location": {
    "DisplayName": "Vesterbrogade"
  },
  "Subject": "Updated title",
  "IsAllDay": true,
  "StartTimeZone": "Central European Standard Time",
  "EndTimeZone": "Central European Standard Time"
}