问题
I'm trying to send a campaing to a segment based on Tags (That is to list members with a specific tag) using API calls with mailchimp3 for Django, but I can't quite find what should be the right json structure to make it, this is what I've got so far:
campaign_creation = {
"type": "regular",
"recipients": {
"list_id": LIST_ID,
"segment_opts": {
"match": "any",
"conditions": [{
"condition_type": "StaticSegment",
"op": "contains",
"field": "Tags",
"value": ["foo"]
}]
}
},
"settings": {
"subject_line": campaign_label,
"title": campaign_label,
"from_name": FROM_NAME,
"reply_to": REPLY_TO,
},
}
But with that I get the error:
mailchimp3.mailchimpclient.MailChimpError: {'type': 'http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/', 'title': 'Invalid Resource', 'status': 400, 'detail': "The resource submitted could not be validated. For field-specific details, see the 'errors' array.", 'instance': '88679b18-6e55-4463-9c62-06d47b825f77', 'errors': [{'field': 'recipients.segment_opts.conditions.item:0', 'message': 'Data did not match any of the schemas described in anyOf.'}]}
Worth to mention that the routine to create and send campaign to the whole list is working perfect, just fails because I've added the segment_opts part
Anyone may have any idea how to make it work? Thanks in advance!
来源:https://stackoverflow.com/questions/63782085/mailchimp-api-send-campaign-to-users-with-tags