Search code examples
outlookmicrosoft-graph-apioutlook-restapi

Failed to accept the event


I am trying to use Microsoft Graph to accept a meeting request.

First I use:

GET /me/messages/{longMessageId}?expand=microsoft.graph.eventMessage/event

I get this response:

{
    "id": "longMessageId",
    "meetingMessageType": "meetingRequest",
    "body": {
        // ...
    },
    "sender": {
        // ...
    },
    // ...
    "event": {
        "id": "longEventId",
        "iCalUId": "longICalUId",
        "attendees": [
            // ...
        ],
        "organizer": {
            // ...
        }
        // ...
    }
}

I set up the access Calendars.ReadWrite first. Then I try to accept the event by:

POST /me/events/{longEventId}/accept

However, I got this error:

{
   "error": {
        "code": "InternalServerError",
        "message": "Object reference not set to an instance of an object.",
        "innerError": {
            "request-id": "882ea5ad-1d92-4f40-95fc-fceab143f0c0",
            "date": "2017-10-14T23:29:21"
        }
    }
}

Solution

  • Make sure that if you are sending a Content-Type header set to application/json, you send a body with the POST. For example:

    {
      "sendResponse": true
    }
    

    If you do not want to send a body, make sure you remove the Content-Type header.