POST Event "The OData request is not supported."

Tim Brown 0 Reputation points
2023-03-14T00:12:06.7533333+00:00

I am getting an error when I try and create a new calendar event using http. Using Application Permissions

https://graph.microsoft.com/v1.0/users/<<upn>>/calendars/events

RESULTS

"error" : 
	{
		"code" : "ErrorInvalidRequest",
		"message" : "The OData request is not supported."
	}

I searched Microsoft and this error does not exist.

I am able to use a GET and receive a list of all the users calendars. (There is only one). The only reference I find regarding this error is when people use a POST instead of PATCH when updating a calendar event.

If you change the POST to:

https://graph.microsoft.com/v1.0/users/<<upn>>/events

I get a different error: UnableToDeserializePostBody : "were unable to deserialize ".

I am not sure what the difference between the two POST urls.

Adding to my question. Could not create comment.

The URL above should be:

https://graph.microsoft.com/v1.0/users/<<upn>>/calendar/events

I had "calendars"

However I still get the next error: UnableToDeserializePostBody : "were unable to deserialize ".

Not sure why.

Thanks.

Tim

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,798 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 5,946 Reputation points
    2023-03-14T02:13:17.62+00:00

    Hi @Anonymous

    You were getting "The OData request is not supported." error message because you were using calendars in this Graph API endpoint https://graph.microsoft.com/v1.0/users/<<upn>>/calendars/events

    If you are using calendars you need to provide {calendar-id} in Graph API endpoint i.e.

    GET /users/{id | userPrincipalName}/calendars/{id}/events

    When you are using this https://graph.microsoft.com/v1.0/users/<<upn>>/calendar/eventsGraph API endpoint this will create event in your default calendar.

    Also, as you have mentioned you are getting "UnableToDeserializePostBody" error now.
    This error generally occurs when request body is invalid, or you are using property which are not present in event resource type properties.

    Please refer to the below sample request to create an event in the specified time zone:

    POST https://graph.microsoft.com/v1.0/me/events
    Prefer: outlook.timezone="Pacific Standard Time"
    Content-type: application/json
    
    {
      "subject": "Let's go for lunch",
      "body": {
        "contentType": "HTML",
        "content": "Does noon work for you?"
      },
      "start": {
          "dateTime": "2023-03-15T12:00:00",
          "timeZone": "Pacific Standard Time"
      },
      "end": {
          "dateTime": "2023-03-15T14:00:00",
          "timeZone": "Pacific Standard Time"
      },
      "location":{
          "displayName":"Harry's Bar"
      },
      "attendees": [
        {
          "emailAddress": {
            "address":"samanthab@contoso.onmicrosoft.com",
            "name": "Samantha Booth"
          },
          "type": "required"
        }
      ],
      "allowNewTimeProposals": true
    }
    

    Reference documentation: https://learn.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&tabs=http#examples

    If you are still facing any issue, please provide screenshot of the request body which you are using along with the error message.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments