python - 使用 mailchimp_transactional 客户端有什么问题?
问题描述
我收到此错误:
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 = {'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 在 mailchimp api文档中为 send_template 方法指定
在 mailchimp_transactional 客户端中,我找到了这段代码,说比只接受“body”作为关键字参数,我应该打开一个问题吗?应该在客户端、文档或 api 上?也许我错过了一些东西,如果是这样的话,对不起。
解决方案
只需将其作为常规body
参数而不是关键字参数传递 - 没有**
. 关键字 params 语法必须在旧版 Mandrill Python API 中使用,Mailchimp Transactional API 不需要它。
result = self.client.messages.send_template(data)
推荐阅读
- python - 在 Python 中发送带有有效负载的 GET 请求
- adobe - Adobe LiveCycle 中带有可流动内容的分页符
- java - 尽管将 rootlogger 设置为 INFO/DEBUG,但只打印错误语句。为什么?
- c# - 如何防止用户选择列表框中的项目,但仍然让代码选择项目?不喜欢使用 enabled = false
- youtube - YouTube 数据 API 未返回预定的直播流
- node.js - 如何在 exec 函数中使用 `cd` 命令指定文件夹位置?
- python - python re.sub 删除数字字符回文
- java - @Timed 和 @Metered 不适用于具有 metrics-jersey2 和生成的 API 接口的 Dropwizard 方法
- php - 如何总结出价相同的所有小鬼..?
- android - Gradle 同步失败:没有 com.android.tools.build:gradle:3.6.1 的缓存版本