3

I'm writing an app that synchronizes with Office365's events using the Microsoft Graph API v1.0.

When creating a single event, the event gets created as expected:

Response Status Code: 201 Created
Request URL: https://graph.microsoft.com/v1.0/me/calendars/<myCalendarId>/events
Request Method: POST
Request Payload:
{
    "subject": "single event",
    "start": {
        "dateTime": "2020-02-15T09:00:00",
        "timeZone": "Europe/Berlin"
    },
    "end": {
        "dateTime": "2020-02-15T10:00:00",
        "timeZone": "Europe/Berlin"
    },
    "attendees": [],
    "type": "singleInstance",
    "location": {
        "displayName": null
    },
    "recurrence": null
}

If, however, I send a create request for a recurring event, I get a error response.

Response Status Code: 500 Internal Server Error
Request URL: https://graph.microsoft.com/v1.0/me/calendars/<myCalendarId>/events
Request Method: POST
Request Payload:
{
    "subject": "test recurring event",
    "start": {
        "dateTime": "2020-02-14T09:00:00",
        "timeZone": "Europe/Berlin"
    },
    "end": {
        "dateTime": "2020-02-14T10:00:00",
        "timeZone": "Europe/Berlin"
    },
    "attendees": [],
    "location": {
        "displayName": null
    },
    "recurrence": {
        "pattern": {
            "daysOfWeek": [],
            "type": "daily"
        },
        "range": {
            "numberOfOccurrences": "2",
            "recurrenceTimeZone": "Europe/Berlin",
            "startDate": "2020-02-14",
            "type": "numbered"
        }
    }
}
Response Body:
{
  "error": {
    "code": "ErrorInternalServerError",
    "message": "An internal server error occurred. The operation failed.",
    "innerError": {
      "request-id": "2d97931c-e08c-45a8-8167-5849df53a694",
      "date": "2020-02-14T14:38:28"
    }
  }
}

I find it strange that the addition of the recurrence settings causes an Internal Server Error. What can I do to create a recurring event with the API?

Eduard
  • 167
  • 1
  • 12
  • What does the response _body_ contain? Often you find a human-readable error message or something like that in there. – misorude Feb 14 '20 at 14:28
  • I've edited the question and added the response body. – Eduard Feb 14 '20 at 14:43
  • Okay, if they really don’t give you more than that, you’d actually need to ask MS. Sometimes such APIs respond with a 500 error code, in places where a 400 Bad Request or similar would be more appropriate. Then you usually get a message back, saying what in particular was wrong about the request. But if this is a “genuine” 500, then probably only MS can tell you, what went wrong. Sometimes these are just temporary issues, so maybe try again in a couple of hours or so. Otherwise, you might have to find the place to file a bug report. – misorude Feb 14 '20 at 14:50

1 Answers1

2

If you want to create a recurring event that occurs daily, instead of setting pattern in the following way:

    "pattern": {
        "daysOfWeek": [],
        "type": "daily"
    },

Please set pattern this way:

"pattern": {
  "type": "daily",
  "interval": 1
},

Creating a daily recurrence pattern is described here in the conceptual docs. Within the next day, there will also be a REST example in the reference docs.

Angelgolfer-ms
  • 336
  • 2
  • 4
  • 1
    Thank you, that solved my problem. I see in the [docs](https://learn.microsoft.com/en-us/graph/outlook-schedule-recurring-events#daily) that `interval` is `required`. Should that not have returned a `400 Bad Request` instead of a `500 Internal Server Error`? – Eduard Feb 27 '20 at 10:50
  • Had a similar issue with absoluteYearly pattern, was missing index in the request and API returned 500 error, which is not cool – Monish Sen Mar 02 '20 at 13:56