在将 SingleValueExtendedProperties 放入图形事件时遇到问题,当我在调试中查看它时,它总是出



我运行以下代码在我的 Outlook 日历上创建一个事件,除了 SingleValueExtendedProperties 为空之外,它确实如此。我逐步浏览了代码,看到@event包含我添加的两个属性,但在我逐步创建 resultPage 之后 - 它的所有内容都正确,除了 SingleValueExtendedProperties 为空。谁能看到我缺少的东西?我花了两天时间通过 https://learn.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;
}
}

这是结果页面和@event上的观看图片:

监视结果页面和@event

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

{URL}events/{id}?$expand=singleValueExtendedProperties($filter=id eq '{your_id}')

相关内容

  • 没有找到相关文章

最新更新