0
votes

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

1

1 Answers

1
votes

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"
}