I created a nice template via the SendGrid UI and am encountering issues trying to send emails with it via the sendgrid python API wrapper (v5.4.1). I've got the template id for a template that has the following (truncated) text:
Hello, {{name}}!
Click the following link to verify your account: {{verification_url}}.
However, when following the example in the documentation, I get a 400 Bad Request error whenever I include the personalizations. I am including the personalizations as follows:
mail.personalizations[0].add_substitution(Substitution("{{name}}", "Example User"))
In addition, mail.get()
returns the following:
{
'from': {
'email': 'test@school.edu'
},
'subject': 'Account Verification',
'personalizations':
[
{
'to': [{'email': 'testemail@test.com'}],
'substitutions': {
'{{name}}': 'Example User'}
}
],
'template_id': '<template_id_here>'
}
Is there any way to debug what's going on? A 400 Bad Request unfortunately isn't all that helpful...
It looks like these features are actually not yet supported: https://github.com/sendgrid/sendgrid-python/issues/591