sendgrid / sendgrid-python

The Official Twilio SendGrid Python API Library
https://sendgrid.com
MIT License
1.53k stars 712 forks source link

400 Bad Request when adding CC for send email #1040

Closed winthebug closed 2 years ago

winthebug commented 2 years ago

Hi,

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 
JenniferMah commented 2 years ago

Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at support.sendgrid.com.