Gaurav Nigam
Gaurav Nigam

Reputation: 21

Outlook REST API future recurring events are getting created with wrong start time

I am using REST API endpoint https://outlook.office.com/api/v1.0/me/events/ to create meeting in Outlook live. The payload of meeting looks like-

{
  "Subject":"Test Meeting",
  "Location":{
    "DisplayName":""
  },
  "Start":"2017-03-02T18:00:00Z",
  "End":"2017-03-02T19:00:00Z",
  "Body":{
    "ContentType":"HTML",
    "Content":"<html><body>Test Meeting Content<\/body><\/html>"
  },
  "Recurrence":{
    "Pattern":{
      "Type":"Weekly",
      "Interval":1,
      "Month":0,
      "Index":"First",
      "FirstDayOfWeek":"Sunday",
      "DayOfMonth":0,
      "DaysOfWeek":["Thursday"]
    },
    "Range":{
      "Type":"EndDate",
      "StartDate":"2017-03-02",
      "EndDate":"2017-03-31"
    }},
    "Attendees":[
      {
        "EmailAddress":{
          "Address":"[email protected]"
        },
      "Type":"Required"
    }
  ]
}

For this weekly recurring event for a month, first two occurrence are getting created at right time but the rest of three meeting events are getting created with an hour delay (instead of 10:00AM UTC, it is 11:00AM UTC).

I even tried with v2.0 endpoint with no luck. I also tried passing timezone for meeting start date and end date, but it is showing same behavior.

Did anyone hit this or similar issue? Any pointers would be of great help, thank you!

Reference to API- https://msdn.microsoft.com/office/office365/APi/calendar-rest-operations#CreateEvents

Upvotes: 2

Views: 285

Answers (1)

Jason Johnston
Jason Johnston

Reputation: 17702

The API is technically behaving correctly here. UTC doesn't change, but the timezone you have configured on your client likely does. In the US Daylight Savings start on March 12, so you see that the appointment "shifts" in the local view so that the appointment always starts at 18:00 UTC, as you specified :)

So my guess is that you want the start time to stay constant across the DST change, so what you really want to do here is specify the timezone for the user in the request. I'd recommend using the v2 API, where the Start and End change types to a DateTimeTimeZone, allowing you to specify the TZ by name:

"Start": {
  "DateTime": "2017-03-02T10:00:00",
  "TimeZone": "Pacific Standard Time"
},
"End": {
  "DateTime": "2017-03-02T11:00:00",
  "TimeZone": "Pacific Standard Time"
},

However, if you need to stay with the v1 API, then you can still specify the TZ in the request, using the StartTimeZone and EndTimeZone properties. The additional work you have to do here is calculate the offsets in the Start and End values. So for example, for Pacific Standard Time, the offset is -08:00 from UTC, so the relevant bit would look like:

"Start": "2017-03-02T10:00:00-08:00",
"StartTimeZone": "Pacific Standard Time",
"End": "2017-03-02T11:00:00-08:00",
"EndTimeZone": "Pacific Standard Time",

Upvotes: 1

Related Questions