I am trying to add HTML as a value in JSON body in below code in PowerShell. It gives 400 Bad Request. The HTML content contains lots of ampersands, quotes, commas etc. due to which this fails. The same code works if I used simple strings instead of web page HTMLs. Is there a way to make this work with web page HTMLs as value in JSON body-
$headers=@{}
$headers.Add("Content-Type", "application/json")
$headers.Add("X-Auth-Email", "")
$response = Invoke-RestMethod -Uri 'https://api.cloudflare.com/client/v4/accounts/account_identifier/storage/kv/namespaces/namespace_identifier/bulk' -Method PUT -Headers $headers -ContentType 'application/json' -Body '[
{
"key": "My-Key",
"value": "Very long HTML of a web page"
}
]'