【问题标题】:Can't add attachment when creating Event with GraphServiceClient使用 GraphServiceClient 创建事件时无法添加附件
【发布时间】:2020-06-03 10:36:09
【问题描述】:

我正在尝试使用带有 GraphServiceClient 的事件创建带有附件的在线团队会议。如果我不提供附件,我可以创建在线会议,但在提供附件时出现以下错误。

ServiceException: 
Code: ErrorAttachmentsNotSupported
Message: Attachments are not supported.
Inner error:
    AdditionalData:
    request-id: cb69967c-3c63-4b04-b232-333d540a51c6
    date: 2020-06-03T10:14:42
ClientRequestId: cb69967c-3c63-4b04-b232-333d540a51c6  

下面是代码

        string OrgnizerUserIdTemp = "userid";

        var aAttachments = new EventAttachmentsCollectionPage();
        byte[] contentbytes = System.IO.File.ReadAllBytes(@"C:\temp\test.pdf");

        aAttachments.Add(new FileAttachment
        {
            Name = "Test.pdf",
            ContentBytes = contentbytes,
            ContentType = "application/pdf",
            ODataType = "#microsoft.graph.fileAttachment",
            Size = contentbytes.Length
        });

        var @event = new Event
        {
            Subject = "Online Meeting for Teams",
            Body = new ItemBody
            {
                ContentType = BodyType.Html,
                Content = "Some body content text here?<BR /> <B>Some Bold Text </B>"
            },
            Start = new DateTimeTimeZone
            {
                DateTime = "2020-06-03T12:00:00",
                TimeZone = "Europe/London"
            },
            End = new DateTimeTimeZone
            {
                DateTime = "2020-06-03T14:00:00",
                TimeZone = "Europe/London"
            },
            Location = new Location
            {
                DisplayName = "Lunch by Heston Blumenthal"
            },
            Attendees = new List<Attendee>()
            {
                new Attendee
                {
                    EmailAddress = new EmailAddress
                    {
                        Address = "AdeleV@sanjayksaxena.onmicrosoft.com",
                        Name = "Adele Vance"
                    },
                    Type = AttendeeType.Required
                },
                new Attendee
                {
                    EmailAddress = new EmailAddress
                    {
                        Address = "sanjay.saxena@sanjayksaxena.onmicrosoft.com",
                        Name = "Sanjay Saxena"
                    },
                    Type = AttendeeType.Required
                },
                new Attendee
                {
                    EmailAddress = new EmailAddress
                    {
                        Address = "user2@gmail.com",
                        Name = "User 2"
                    },
                    Type = AttendeeType.Optional
                }
            },
            IsOnlineMeeting = true,
            AllowNewTimeProposals = true,
            TransactionId = "7E163156-7762-4BEB-A1C6-729EA81755A1",
            Attachments = aAttachments, 
            HasAttachments = true
        };

        var om = graphServiceClient.Users[OrgnizerUserIdTemp].Events
            .Request()
            .Header("Prefer", "outlook.timezone=\"Europe/London\"")
            .AddAsync(@event).Result;

有没有办法给活动添加附件? 或者 如果有任何其他方法可以创建带有附件的 Teams 在线会议。任何帮助将不胜感激。

【问题讨论】:

    标签: c#-4.0 microsoft-graph-api


    【解决方案1】:

    onlineMeeting resource type 不支持添加附件。 但是您可以创建带有附件的日历事件,但它有一些限制。 请找到以下链接,了解如何将附件添加到日历活动here

    日历附件的限制: 您只能将附件对象添加到用户日历中的事件,但不能添加到组日历中的事件。

    【讨论】:

    • 感谢您的回复。我对 Microsoft Graph 很陌生。您能否告诉用户日历和组日历之间的区别?或者,请分享一篇文章。
    • 从 microsoft here 的 api 文档开始。在日历部分下,您可以看到日历、日历组、事件 API,这些 API 将引导您浏览 API 和请求正文。 @SanjaySaxena
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 1970-01-01
    • 2022-06-25
    • 1970-01-01
    相关资源
    最近更新 更多