如何使用Microsoft.Graph向Outlook 365事件添加扩展? [英] How to add an Extension to Outlook 365 event using Microsoft.Graph?

查看:54
本文介绍了如何使用Microsoft.Graph向Outlook 365事件添加扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft.Graph创建Office365日历事件.它工作正常,我可以创建一个事件,但是我需要为事件添加几个额外的字符串属性,因此我为此创建了一个扩展.它编译良好.但是,当我尝试运行它并创建一个具有扩展名的事件时,它会引发错误:

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:

代码:RequestBodyRead消息:类型'Microsoft.OutlookServices.Extension'上不存在属性'extensionName'.确保仅使用由类型定义的属性名称,或将类型标记为开放类型.

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.

推荐答案

添加ODataType对我有用:

Adding the ODataType has worked for me:

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

这篇关于如何使用Microsoft.Graph向Outlook 365事件添加扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆