rest - mailchimp3 (Python-mailchimp-api) 如何设置标签

标签 rest api mailchimp

我尝试过:

    client.lists.members.create('1111111', {
        'email_address' : '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89e8a979f9f9d8ac9c9ceb89f95999194d69b9795" rel="noreferrer noopener nofollow">[email protected]</a>',
        'status'        : 'subscribed',
        "tags": [{'name': 'frogger', 'status' : 'active'}],  
    })

并得到:

mailchimp3.mailchimpclient.MailChimpError: {
    'type': 'http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/',
    'title': 'Invalid Resource', 
    'status': 400, 
    'detail': 'Expected argument of type "string", "stdClass" given',
    'instance': '5ae1b966-ed35-49f1-ad32-0a39c3d63593'
}

没有“tags”行,语句就可以工作

最佳答案

这对我有用(您需要对电子邮件地址进行哈希处理)

hash = get_subscriber_hash(email_address) 

data = {
        'tags': [
            {'name': 'foo', 'status': 'active'},
            {'name': 'bar', 'status': 'inactive'}
        ]
}

client.lists.members.tags.update(list_id=list_id, subscriber_hash=hash, data=data)

关于rest - mailchimp3 (Python-mailchimp-api) 如何设置标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61209207/

相关文章:

java - postman 显示错误 : format not supported by the requested resource

api - 如何在Golang中从服务器发送Websocket

php - 将 API JSON 响应存储在 SQL 数据库中

javascript - 如何让 Mailchimp 弹出窗口在 Chrome 中工作

javascript - MC :edit do not work in Mailchimp template with Mandrill Javascript API

django - 我有一个中间件,我想在其中记录每个请求/响应。如何访问 POST 数据?

c# - Xamarin 表单添加对 Web 服务的引用

java - 未找到 Java 类的消息正文编写器

node.js - Salesforce Oauth重定向CORS问题 Node express 应用程序

api - Mailchimp API merge_var 地址...如何创建城市列表?