I'm using this as part of the runbook in Azure. The email works fine if I'm only using the To field for emails
$jsonRequest = [ordered]@{
personalizations= @(@{to = @(@{email = "$To"})
subject = "$SubJect" })
from = @{email = "$From"}
content = @( @{ type = "text/HTML"
value = "$Body" }
)} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Uri "https://api.sendgrid.com/v3/mail/send" -Method Post -Headers $headers -Body $jsonRequest
However if I'm adding the CC field, then I get 400 Bad request error. Is there another way to incorporate CC into the same request?
$jsonRequest = [ordered]@{
personalizations= @(@{to = @(@{email = "$To"})
cc = @{email = "$cc"}
subject = "$SubJect" })
from = @{email = "$From"}
content = @( @{ type = "text/HTML"
value = "$Body" }
)} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Uri "https://api.sendgrid.com/v3/mail/send" -Method Post -Headers $headers -Body $jsonRequest