How can I add a HTML body for a Calendar event to an array and convert to JSON for event PATCH

Occasional Contributor

 

I am trying to update Calendar Events via GRAPH and to succesfully replace the event message body I must pack the HTML body into a JSON file.  I have been successful using simple html test content.  But, when I try to use a real message body gathered via GET EVENT and then edited via my script it fails.    ConvertTo-Json does not like the complex html in the real message body.

 

Does anyone have any advice or functions for importing HTML into a JSON structure?

                              
                                $json = @{
                                    body=@
                                        "contentType"= "HTML";
                                        "content" = $fixedHTMLBody;
                                    }
                                } | ConvertTo-Json -Depth 90 -EscapeHandling Default      
 
1 Reply
This now works on Powershell v7. That is my answer...