I am generating Outlook Actionable Messages via Powershell. I need to put JSON in the body of an HTTP post request like this example for Microsoft's site (please note the example is just above this link, I can't copy and paste for some reason, so please scroll up a little after you click it)
I've noticed that the. "body": "{{nameInput.value}}" portion needs to be JSON but escape characters are required or it does not work. Is there a good way in Powershell to generate this output? I have created Powershell objects and used convertto-json, which creates JSON but not with the appropriate escape characters.
Here's an example of an object created in PowerShell
$appointment = [pscustomobject]@{
Subject = "Foo"
}
Converting that to JSON gives me this:
$appointment | ConvertTo-Json
{
"Subject": "Foo"
}
However, when I put this in the http POST body, I need something like this:
"body":
"{
\"subject\":\"foo\"
}",
Note the escaping around the quotation marks.
Thanks!