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': 'noreply@ex.com', 'from_name': 'Ex', 'subject': "some string", 'to': [{'email': 'ex@example.com', '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.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.