0

Creating calendar events with recurrence field fails. Here are sample request payload from Chrome Network tab:

Successful (without Recurrence field):

Attendees: []
Body: {ContentType: "HTML", Content: ""}
End: "2015-05-14T16:29:40.307Z"
Start: "2015-05-14T16:29:40.307Z"
Subject: "Regular event"

Failing request (with Recurrence field): Request screenshot

Attendees: []
Body: {
  ContentType: "HTML",
    Content: ""
}
End: "2015-05-14T16:29:40.307Z"
Recurrence: {
  Pattern: {
    DayOfMonth: 0
    FirstDayOfWeek: "Sunday"
    Interval: 1
    Month: 0
    Type: "Daily"
  }
  Range: {
    EndDate: "2015-05-23T00:00:00+03:00"
    NumberOfOccurences: 0
    StartDate: "2015-05-17T00:00:00+03:00"
    Type: "EndDate"
  }
}
Start: "2015-05-14T16:29:40.307Z"
Subject: "Regular event"

In the above case the error that the server returns is the following one:

"error": {
    "code": "ErrorInvalidRequest",
    "message": "Cannot read the request body."
}

Can anyone check the above request and tell me what is missing from the recurrence rule and prevent saving the calendar event? Or the API currently doesn't support creating recurring events?

Url used for requests: https://outlook.office365.com/api/v1.0/me/events

Request Method: POST

Vladimir Iliev
  • 1,871
  • 16
  • 26

1 Answers1

1

It looks like your Recurrence entry is missing the wrapping '{}', and there are no commas between the subfields. Since the OData reader on the server can't parse it, it throws that "Can't read the request body" error.

Try:

{
  Attendees: [],
  Body: {
    ContentType: "HTML",
    Content: ""
  },
  End: "2015-05-14T16:29:40.307Z",
  Recurrence: {
    Pattern: {
      DayOfMonth: 0,
      FirstDayOfWeek: "Sunday",
      Interval: 1,
      Month: 0,
      Type: "Daily"
    },
    Range: {
      EndDate: "2015-05-23T00:00:00+03:00",
      NumberOfOccurrences: 0,
      StartDate: "2015-05-17T00:00:00+03:00",
      Type: "EndDate"
    }
  },
  Start: "2015-05-14T16:29:40.307Z",
  Subject: "Regular event"
}
Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • The request is get from the Chrome Network tab - therefor it's marked as an object, however when you copy the text the wrapping brackets are not copied. The brackets are actually there: Recurrence:{Pattern: {Type: "Daily", Interval: 1, FirstDayOfWeek: "Sunday", Month: 0, – Vladimir Iliev May 14 '15 at 19:02
  • I added request screenshot for reference. – Vladimir Iliev May 14 '15 at 19:15
  • 1
    AH! There's a typo in your NumberofOccurrences field name. You only have one 'r'. I originally didn't cut/paste your request, so I didn't reproduce the error. – Jason Johnston May 14 '15 at 19:35
  • Maybe this has changed from v1.0 to v2.0, or maybe it differs from language to language (I doubt it), but for me the `StartDate` and `EndDate` values within the `Range` property had to be just the date (eg `2015-05-23`), otherwise it would complain that it needed the data to be of `Edm.Date` type. Hope it helps someone. – Luca Bezerra Dec 16 '16 at 15:34
  • Yes, this did change from v1.0 to v2.0. – Jason Johnston Jan 03 '17 at 17:25