Unable to get OpenTypeExtensionProperty for event using Graph API

Mahesh Tibrewal 51 Reputation points
2020-11-23T13:17:40.5+00:00

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

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

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

Accepted answer
  1. Deva-MSFT 2,256 Reputation points Microsoft Employee
    2020-11-23T20:28:31.59+00:00

    You can do this in two steps...
    (1) Create an event and add opentypeextension part of it
    (2) Get the event/opentypeextension

    First, i used Microsoft Graph explorer to create the event. I made sure to add opentypeextension to it:

    41965-image.png

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

    41878-image.png

    So my code would look like the below:

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

2 additional answers

Sort by: Most helpful
  1. Mahesh Tibrewal 51 Reputation points
    2020-11-24T03:48:14.62+00:00

    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

    0 comments No comments

  2. Deva-MSFT 2,256 Reputation points Microsoft Employee
    2020-11-24T03:59:03.51+00:00

    Glad that the above helped you moving forward. Yes, you get the error as the extension not available in the items/store. I see that you have a workaround to move forward.

    0 comments No comments