1

我运行以下代码在我的 Outlook 日历上创建一个事件,除了 SingleValueExtendedProperties 为空之外,它确实如此。我逐步浏览了代码,发现@event 包含我添加的两个属性,但是在我逐步创建 resultPage 之后 - 除了 SingleValueExtendedProperties 为空之外,它的所有内容都是正确的。谁能看到我缺少的东西?我花了两天时间浏览 https://docs.microsoft.com/en-us/graph/页面。

这是我的代码:

        public static async Task<Event> PostNewEventAsync()
    {
        try
        {
            var extendedProperties = new EventSingleValueExtendedPropertiesCollectionPage();

            extendedProperties.Add(new SingleValueLegacyExtendedProperty
            {
                Id = "Boolean {" + OwnedByGuid + "} Name OwnedByTony",
                Value = true.ToString()
            });

            extendedProperties.Add(new SingleValueLegacyExtendedProperty
            {
                Id = "Long {" + LocalAppointmentIdGuid + "} Name AppointmentId",
                Value = "12345",
            });

            var @event = new Event
            {
                Subject = "Wear a suit tomorrow",
                Body = new ItemBody
                {
                    ContentType = BodyType.Html,
                    Content = "Does late morning work for you?"
                },
                Start = new DateTimeTimeZone
                {
                    DateTime = "2020-01-15T18:00:00",
                    TimeZone = "UTC"
                },
                End = new DateTimeTimeZone
                {
                    DateTime = "2020-01-15T20:00:00",
                    TimeZone = "UTC"
                },
                Location = new Location
                {
                    DisplayName = "Jimmys Cafe"
                },
                Attendees = new List<Attendee>()
                {
                    new Attendee
                    {
                        EmailAddress = new EmailAddress
                        {
                            Address = "JavaJoe@cafe.com",
                            Name = "Java Joe"
                        },
                        Type = AttendeeType.Optional
                    }
                },
                Organizer = new Recipient
                {
                    EmailAddress = new EmailAddress
                    {
                        Address = "TwoToneTony@cafe.com",
                        Name = "TwoTone Tony"
                    }
                },

                SingleValueExtendedProperties = extendedProperties
            };

            var resultPage = await graphClient.Me.Events.Request()
                .Header("Prefer", "outlook.timezone=\"Mountain Standard Time\"")
                .AddAsync(@event);

            return resultPage;
        }
        catch (ServiceException ex)
        {
            Console.WriteLine($"Error posting event: {ex.Message}");
            return null;
        }
    }

这是 resultPage 和 @event 上的观看图片:

注意 resultPage 和 @event

4

1 回答 1

0

响应将不具有该属性。请使用扩展查询字符串再次调用 API,如下所示

{URL}events/{id}?$expand=singleValueExtendedProperties($filter=id eq '{your_id}')
于 2021-06-11T15:09:11.717 回答