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!
It may be old question, but here's the answer - your StaticSegment object may be wrong. It works like that in my case, however if you want to use multiple tags, then maybe the correct way to do it is by adding another StaticSegment for each tag. Also, you pass foo and I assume you know this should be the tag id.
'conditions' => [
[
'condition_type' => 'StaticSegment',
'field' => 'static_segment',
'op' => 'static_is',
'value' => $tagId
]
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With