Mailchimp api v3 - can't create segment based on a TEXT merge field

843 Views Asked by At

I'm trying to create a segment based on a new merge field of type TEXT that I just created, by using condition_type = TextMerge since it seems to be the only option from their documentation that matches my field: http://developer.mailchimp.com/documentation/mailchimp/reference/lists/segments/#create-post_lists_list_id_segments

However, the description for TextMerge looks identical to EmailAddress. To be more specific they both apply only for the EMAIL / MERGE0 field.

TextMerge vs EmailAddress

I tried the following combinations for 'conditions':

{
    'condition_type': 'TextMerge',
    'field': 'EVENTS',
    'op': 'contains',
    'value': 'test'
}

and

{
    'condition_type': 'TextMerge',
    'field': 'EMAIL',
    'op': 'contains',
    'value': 'test'
}

The first one returns an error:

{
    "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":"",
    "errors":
    [
        {
            "field":"options.conditions.item:0",
            "message":"Data did not match any of the schemas described in anyOf."
        }
    ]
}

The second one works.

My question is: how can I create a segment based on a custom merge field of type TEXT? To me this looks like a bug from their side. Did anyone else have this problem? Does anyone have a solution?

1

There are 1 best solutions below

0
tolgap On

I finally managed to solve my issue specific to TEXT fields in my mailchimp audience merge tags.

Apparently, when adding a TEXT field, it defaults to a maximum size of 25 characters. I was trying to put more text than that into it. It fails with the error:

@body={
  "title"=>"Invalid Resource",
  "status"=>400,
  "detail"=>"The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
  "errors"=>[{"field"=>"merge_fields.MMERGE_16",
  "message"=>"Data did not match any of the schemas described in anyOf."}]
}

I increased the field size to 255 via Mailchimp's API.