'What's wrong using the mailchimp_transactional client?
I getting this error :
File "/Users/hernan0216/services/project/services/email.py", line 84, in _send_template
result = self.client.messages.send_template(**data)
File "/Users/hernan0216/services/venv/lib/python3.6/site-packages/mailchimp_transactional/api/messages_api.py", line 422, in send_template
(data) = self.send_template_with_http_info(body, **kwargs) # noqa: E501
File "/Users/hernan0216/services/venv/lib/python3.6/site-packages/mailchimp_transactional/api/messages_api.py", line 438, in send_template_with_http_info
" to method send_template" % key
TypeError: Got an unexpected keyword argument 'template_name' to method send_template
data should be something like this
data = {'template_name': 'name_template', 'template_content': [], 'message': {'from_email': '[email protected]', 'from_name': 'Ex', 'subject': "some string", 'to': [{'email': '[email protected]', 'name': 'Example', 'type': 'to'}], 'global_merge_vars': [{'name': 'STUDENT_NAME', 'content': 'Example Name'}]}}
Like is specified on the mailchimp api docs for the send_template method
In the mailchimp_transactional client I found this code, that say than accepts only "body" as keyword argument, should I open an issue? Should be on the client, docs or api ?? Maybe I'm missing something, if that the case, sorry.
Solution 1:[1]
Just pass it as a regular body argument instead of keyword arguments - without **. The keyword params syntax had to be used in legacy Mandrill Python API, the Mailchimp Transactional API does not require it.
result = self.client.messages.send_template(data)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Burnes |
