I have created an event in the outlook calendar. The event contains Teams join link. While I am updating the event from MS Graph API, the join button is being removed.
Here is the sample code of what I am doing:
void UpdateEventInCalendar(string eventId)
{
var getCalEvent = Task.Run(() =>
{
return service.Me.Events[eventId].Request().GetAsync();
});
Task.WaitAll(getCalEvent);
BodyType bodyType = BodyType.Text;
Event eventToUpdate = getCalEvent.Result;
Event updatedEvent = new Event();
updatedEvent.Id = eventToUpdate.Id;
updatedEvent.Subject = "Updated text";
updatedEvent.ShowAs = eventToUpdate.ShowAs;
updatedEvent.Body = new ItemBody
{
ContentType = bodyType,
Content = "Some new content"
};
graphServiceClient.Me.Events[updatedEvent.Id].Request().UpdateAsync(updatedEvent.Id);
}
Event before update:
Event update content:
Event after update:
How to keep the event while updating the event?
As a workaround you can try this to keep your online meeting appeared:
First: in your addEvent function, your body should be like this
AddedEvent.Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "<p id = 'MsgContent'>Your Body</p>"
};
Second: In the update event, you can change the body content like this
HtmlDocument html = new HtmlDocument();
html.LoadHtml(EventToUpdate.Body.Content);
html.GetElementbyId("Msgcontent").InnerHtml = "Your new body";
updatedEvent.Body = EventToUpdate.Body;
updatedEvent.Body.Content = html.DocumentNode.OuterHtml;