Unable to get OpenTypeExtensionProperty for event using Graph API

139 views Asked by At

For one of our application, I am trying to get Extensions for an event using the following code in C#:

var result = graphServiceClient.User[userid].Calendar.Events[eventid].Extensions.Request().GetAsync().Result;

However, I am getting following exception:

Code: ErrorInvalidRequest Message: The OData request is not supported. ClientRequestId: f7a44c2f-ca79-4f79-9726-2cdc98d87e00

I found the above code in few of the questions posted on stackoverflow.

We need to add and get opentype extensions by any means. Can somebody please help?

2

There are 2 answers

0
Dev On BEST ANSWER

First, i used Microsoft Graph explorer to create the event and add opentypeextension to it:

enter image description here

Then get the opentypeextensions for the above event using its id:

enter image description here

Code will look like this:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var extension = await graphClient.Me.Events["'AAMkAGRlNWYmM5YjIzNTRhMwBGAAAAAAA-AAA='"].Extensions["Com.Contoso.Referral"]
    .Request()
    .GetAsync();

1
Mahesh On

The above worked for me, however in my case I wanted to check all outlook events for the specific extension and in case the extension is not present in any one of the events, I was get the following error:

Code: ErrorItemNotFound Message: The specified object was not found in the store. ClientRequestId: a65d0d31-123b-4834-9bec-8d471d22b6e0

To resolve above, while iterating through all events I added the code for fetching extension in try catch block and added following code in catch block to continue the loop in case we have above exception

if (ex.InnerException.GetType() == typeof(ServiceException) &&
                    ex.InnerException.Message.Contains("Code: ErrorItemNotFound"))
                    continue;

Anyways my issue is resolved now. Thanks for the help