Closed akaushik759 closed 4 years ago
It looks like this issue may have been fixed in #908. You can check by installing this library locally, or wait until the fix is rolled out in the next release on 2020-06-24
I don't think that will help. Best to log the error body response to see a more detailed reason for the failure. Example here: https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/error_handling.md
I don't think that will help. Best to log the error body response to see a more detailed reason for the failure. Example here: https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/error_handling.md
I did that and here is the response
b'{"errors":[{"message":"Substitutions may not be used with dynamic templating","field":"personalizations.0.substitutions","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.substitutions"},{"message":"Substitutions may not be used with dynamic templating","field":"personalizations.1.substitutions","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.substitutions"}]}'
@eshanholtz I tried the #908 fix, but it still throws up error, not sure what I am doing wrong.
to_emails = [ To(email='test+to0@example.com', name='Example Name 0', dynamic_template_data={ 'name': 'Dynamic Name 0', 'url': 'https://example.com/test0', }, subject='Override Global Subject'), To(email='test+to1@example.com', name='Example Name 1', dynamic_template_data={ 'name': 'Dynamic Name 1', 'url': 'https://example.com/test1', }), ]
I got another exception for this :
TypeError: __init__() got an unexpected keyword argument 'dynamic_template_data'
Will the fix for this specific issue (substitution support for dynamic templates) be released on 2020-06-24?
The fix will be to switch from using substitutions
to dynamic_template_data
in your code. Support for doing this via the To()
initializer will be released on 2020-06-24.
Issue Summary
I am trying to send multiple emails using a Dynamic Template, with each email having their own unique substitutions using the Mail Helper class. If I don't include the substitutions then the code works perfectly and mails are delivered, but as soon as I include substitution I get a "HTTP Error 400: Bad Request". I am using Virtual Environment and running it in my Flask app. I have installed sendgrid using "pip install sendgrid" and its updated to the latest version.
Code Snippet
Exception/Log
Technical details:
I tried upgrading and this is what it prints