Updating event via MS Graph API removing Join Button in the event

1.4k Views Asked by At

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 before updating

Event update content:

Update event content

Event after update:

enter image description here

How to keep the event while updating the event?

3

There are 3 best solutions below

3
On BEST ANSWER

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;
1
On

Try not updating the body and you will be able to make it work. See this thread. Yes, if you update the body without isonlinemeeting, the teams meeting blob will be removed and this makes the isonlinemeeting property to false and we are loosing the button.

0
On

I faced the same issue and I got out with this solution, hope it helps.

You create an online event through the API with an empty body. The response from the server contains the HTML body with the join link and you store it. Then, if you update the event preserving all the online meeting related content, the event keeps having the join button, so you get the needed result.

If you update the event body deleting the online meeting related content, you loose the join button and, according to the docs, there's not much you can do about it.