Update existing calendar event, how to manage and add complex HTML content to a JSON property?

Copper Contributor

<NEWBIE>  We are working on a tool that would scan calendar events, read and then update the calendar event HTML body.   Our goal is to scan existing events for online Team's meeting and fix the URL's that were broken during mailbox migration.  

 

We were successful testing PATCH and replacing the existing event HTML event body using a very simple HTML content below. The Invoke-RestMethod -Method "PATCH" requires us to use a formatted JSON file like this which was successful at overwriting the existing events HTML body as a test.

Simple, successful JSON body below did update the existing event:

{
"body": {
"contentType": "HTML",
"content": "<HTML><div><B>This is bold text!</B> This is not bold text... </div></HTML>"
}
}

 

Our current issue is how do we add COMPLEX HTML content to the JSON Body.content property without breaking the JSON validation?  We need some guidance on how you would approach reading the existing event body, modifying an existing <A hyperlink within the content, then save the  corrected HTML back to the event.  

 

The below JSON body which was originally read from the event and had a <A hyperlink modified failed validation at line 4 which was the opening <HTML> text tag.  We have not found any documentation that helps with managing HTML within JSON.

 

{
"body": {
"contentType": "HTML",
"content": "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="text/html; charset=us-ascii">
</head>
<body>
<br>
<div style="width:100%; height:20px"><span style="white-space:nowrap; color:#5F5F5F; opacity:.36">________________________________________________________________________________</span>
</div>
<div class="me-email-text" style="color:#252424; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif">
<div style="margin-top:24px; margin-bottom:20px"><span style="font-size:24px; color:#252424">Microsoft Teams meeting</span>
</div>
<div style="margin-bottom:20px">
<div style="margin-top:0px; margin-bottom:0px; font-weight:bold"><span style="font-size:14px; color:#252424">Join on your computer or mobile app</span>
</div>
<a class="me-email-headline" href="https://teams.microsoft.com/l/meetup-join/19:meeting_MDM1OTgwYzUtZTU4My00Y2VkLTljYzgtNDAzYmQzYWFlYzJk@thread.v2/0?context=%7b%22Tid%22%3a%22b61d9528-c1d8-4637-8ed5-f61771d5ca19%22%2c%22Oid%22%3a%2211111111-2222-3333-4444-555555555555%22%7d" target="_blank" rel="noreferrer noopener" style="font-size:14px; font-family:'Segoe UI Semibold','Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif; text-decoration:underline; color:#6264a7">Click
here to join the meeting</a> </div>
<div style="margin-bottom:4px">
<div style="margin-bottom:4px"><span style="font-size:14px; color:#252424; font-weight:bold">Or call in (audio only)</span>
</div>
<div style="margin-bottom:4px"><a href="tel:+13236734336,,435656748# " style="font-size:14px; text-decoration:underline; color:#6264a7">+1 323-673-4336,,435656748#</a>
<span style="font-size:14px; color:#252424">&nbsp; United States, Los Angeles </span></div>
</div>
<span style="font-size:14px; color:#252424">Phone Conference ID: </span><span style="font-size:16px; color:#252424">435 656 748#
</span>
<div style="margin-bottom:20px"><a class="me-email-link" target="_blank" href="https://dialin.teams.microsoft.com/ff6397c2-bb2f-452d-af22-68cb43c8bbea?id=435656748" rel="noreferrer noopener" style="font-size:14px; text-decoration:underline; color:#6264a7; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif">Find
a local number</a> | <a class="me-email-link" target="_blank" href="https://mysettings.lync.com/pstnconferencing" rel="noreferrer noopener" style="font-size:14px; text-decoration:underline; color:#6264a7">
Reset PIN</a> </div>
<div style="margin-bottom:24px; margin-top:20px"><a class="me-email-link" target="_blank" href="https://aka.ms/JoinTeamsMeeting" rel="noreferrer noopener" style="font-size:14px; text-decoration:underline; color:#6264a7; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif">Learn
More</a> | <a class="me-email-link" target="_blank" href="https://teams.microsoft.com/meetingOptions/?organizerId=1cb22611-5110-42cb-8c6d-0b0ad201f187&amp;ten..." rel="noreferrer noopener" style="font-size:14px; text-decoration:underline; color:#6264a7; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif">
Meeting options</a> </div>
</div>
<div style="font-size:14px; margin-bottom:4px; font-family:'Segoe UI','Helvetica Neue',Helvetica,Arial,sans-serif">
</div>
<div style="font-size:12px"></div>
<div style="width:100%; height:20px"><span style="white-space:nowrap; color:#5F5F5F; opacity:.36">________________________________________________________________________________</span>
</div>
</body>
</html>
"
}
}

 

Thanks, Stu

 

0 Replies