3

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?

Amit Singh
  • 426
  • 1
  • 4
  • 11
  • Try not updating the body and you will be able to make it work. See this [thread](https://github.com/microsoftgraph/microsoft-graph-docs/issues/10618). – Shiva Keshav Varma Dec 08 '20 at 16:42
  • 1
    @Shiva-MSFTIdentity how about the reverse, is it also possible to add the teams meeting link part to the event body and have the join button appear? – Stephan Dec 08 '20 at 21:56
  • @Shiva-MSFTIdentity My use case involves updating the body also. Is it possible to acheive? – Amit Singh Dec 09 '20 at 11:00
  • @Stephan You can't do that because there is another property called isonlinemeeting with is getting toggled while updating the body. So try not to update the body, it will work. – Shiva Keshav Varma Dec 09 '20 at 11:11
  • @AmitSingh As said in the github link I was also facing the same issue, so in your scenario try testing updating the body until the isonlinemeeting is equal to true and then stop. Remember when ever isonlinemeeting toggles, the meeting url changes. Give it a try and see if this can help. – Shiva Keshav Varma Dec 09 '20 at 11:17
  • @Shiva-MSFTIdentity In my case, I have also tried updating the body only, not changing the isOnlineMeeting property(or any other property). Still, the Join Button is disappearing – Amit Singh Dec 09 '20 at 11:45
  • Yes, if you update the body without isonlinemeeting, the teams meeting blob will be removed and this makes the isonlinemeeting property to false. – Shiva Keshav Varma Dec 09 '20 at 11:57
  • Does the above helped? – Dev Dec 12 '20 at 18:54
  • @Dev Things will only work if you do not update the body. If you update the body, the Join button will be removed. – Amit Singh Dec 16 '20 at 05:36
  • Agreed @AmitSingh. As Shiva updated this is the same recommendation/update you notice in the [above thread](https://github.com/microsoftgraph/microsoft-graph-docs/issues/10618). – Dev Dec 16 '20 at 06:19
  • Moving this to answer. Hi, if the posted answer resolves your question, please mark it as the answer by clicking the check mark. Doing so helps others find answers to their questions. See https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work. – Shiva Keshav Varma Dec 18 '20 at 10:37

3 Answers3

4

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;
ElHalwany
  • 66
  • 7
  • @M Elhalwany and @Amit Singh where to write second part of code? – Kinjal Gor Apr 07 '21 at 13:02
  • as i also want to change the body part and also want Join meeting button n email – Kinjal Gor Apr 07 '21 at 13:03
  • @KinjalGor You can write the second part where you want to update the code. In my case, I was creating the event in one API call and updating the data in another API call. If you want to do it in one go, you can create the event and immediately update it. – Amit Singh Apr 28 '21 at 18:35
0

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.

Shiva Keshav Varma
  • 3,398
  • 2
  • 9
  • 13
  • Why would this even be a solution? This is just a workaround because if you really need to update the body you just cant do this. – Hugo Vinhal Sep 30 '22 at 11:13
0

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.

heyman_71
  • 86
  • 1
  • 6