How to add an Extension to Outlook 365 event using Microsoft.Graph?

不问归期 提交于 2021-01-28 09:22:34

问题


I'm using Microsoft.Graph to create an Office365 calendar event. It works fine and I can create an event but I need to add a couple of extra string properties to an event, so I've created an extension for that. It compiles fine. But when I try to run it and create an event with added extension, it throws an error:

Code: RequestBodyRead Message: The property 'extensionName' does not exist on type 'Microsoft.OutlookServices.Extension'. Make sure to only use property names that are defined by the type or mark the type as open type.

        //Extension
        var evExtCollPage = new EventExtensionsCollectionPage();
        var dict = new Dictionary<string,object>();
        dict.Add("eSmtTickeId", "123");
        dict.Add("siteId", "456");
        var openExtension = new OpenTypeExtension
        {
            ExtensionName = "com.TechApp.Extensions",
            AdditionalData = dict
        };
        evExtCollPage.Add(openExtension);


        Event createdEvent = await graphClient.Me.Events.Request().AddAsync(new Event
        {
            Subject = "Service appointment",
            Location = location,
            Attendees = attendees,
            Body = body,
            Start = startTime,
            End = endTime,
            Extensions = evExtCollPage
        });

What is wrong with my extension? I've struggled with this for 3 days now.


回答1:


Adding the ODataType has worked for me:

var openExtension = new OpenTypeExtension
{
    ODataType = "microsoft.graph.openTypeExtension",
    ExtensionName = "com.TechApp.Extensions",
    AdditionalData = dict
};


来源:https://stackoverflow.com/questions/49073470/how-to-add-an-extension-to-outlook-365-event-using-microsoft-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!