0

I have been searching for a solution for this problem and it seems like any answer is helping me.

I am trying to do a patch on an Event using the graph client, like this:

graphClient.me().events(eventId).buildRequest().patchAsync(graphEvent);

As it says in the documentation, if I need to update the body of the Event, I need to get the old one and only make changes to its content, like I am doing here:

oldEvent.body.content = "new content";

In the documentation is also mentioned that I need to preserve the meeting blob for the online meeting, but what does this mean? Am I doing anything wrong here? I am literally just setting the content of the body and the meeting url just gets lost because of it.

There are several threads online that also say that I should not update the body for this to work, and despite that "solution" being valid, it is not a solution, it is just a workaround because in my case I really need to be able to update the body content of the event without losing the link!

I am doing this in Java and using the 5.18.0 microsoft-graph dependency version if that helps.

Hugo Vinhal
  • 305
  • 1
  • 15

1 Answers1

0

It looks like the body of the original event is appended with text relating to the Teams Meeting. When you set the body in the updated event, you are overwriting it. Refer to

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

You need to get the existing event and the update only part of the body. Something like

Event existingEvent = graphClient.users(senderEmail).events(eventId).buildRequest().get();

Event event = new Event();
ItemBody body1 = new ItemBody();
    
body1.contentType = BodyType.HTML;
String existingContent = existingEvent.body.content;
int startBody = existingContent.indexOf("=\"PlainText\">");
int endBody = existingContent.indexOf(".....");
String replaced = existingContent.substring(0, startBody + 13) + 
templateBody.replace("\n", "<br/>") + existingContent.substring(endBody);
body1.content = replaced;
event.body = body1;
Samir Seetal
  • 392
  • 6
  • 8