I run the following code to create an Event on my Outlook calendar, which it does except that the SingleValueExtendedProperties is null. I stepped thru the code and saw that @event contains both properties as I had added but after I step thru creating the resultPage - it has everything correct except SingleValueExtendedProperties is null. Can anyone see something that I am missing? I've spent two days going thru https://learn.microsoft.com/en-us/graph/ pages.
This is my code:
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;
}
}
Here is pic of watch on resultPage and @event: