I try to send from within Powershell 7 (on Windows) to a Teams Webhook.
If i send a formatted string, it works. If i send the same string via a variable, it brakes. Any idea?
PS Microsoft.PowerShell.Core\FileSystem::\AD> $body = "`'{`"text`":`"mailbody`"}`'"
PS Microsoft.PowerShell.Core\FileSystem::\AD> $boDY
'{"text":"mailbody"}'
PS Microsoft.PowerShell.Core\FileSystem::\AD> Invoke-RestMethod -Method Post -ContentType 'Application/Json' -Body $body -Uri $mychat
Invoke-RestMethod: Bad payload received by generic incoming webhook.
PS Microsoft.PowerShell.Core\FileSystem::\AD> Invoke-RestMethod -Method Post -ContentType 'Application/Json' -Body '{"text":"mailbody"}' -Uri $mychat
1