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

1

2

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?

Arnulfo answered 13/1, 2017 at 13:39 Comment(10)
Can you add the complete error response? It should be a json with errors as an array.Kelliekellina
Yes, I added it, but it doesn't contain any relevant information.Arnulfo
The only way I can get the exact same response as you is if condition_type or op has an invalid value, or both condition_type and op have invalid values. For example condition_type is TextMerge2 or op is contains2. Based on your conditions parameter, looks like this is the problem: 'op: 'contains', are you sure it's not a typo? It should be 'op': 'contains' (notice the quote after op).Kelliekellina
:) I manually wrote that in here. No typos in the code. As I said, if I change the field to EMAIL it works. Did you successfully create a segment based on a text field?Arnulfo
Yes I actually did using c#. What technology are you using to make the request? curl, php, c#, python, or something else?Kelliekellina
I envy you. I'm using PHP.Arnulfo
You should add your php code to your question and add [php] tag so hopefully other people with php skills could help. If you're using some kind of php wrapper, then it's possible that the wrapper messes the request body somehow since I could successfully create the segment using c#. You could also contact MailChimp support team, just to make sure that this is not a bug from their end.Kelliekellina
Will do. Thank you. I already posted a question to the MC team.Arnulfo
@GabrielaRaducan Did you ever resolve this?Deepset
@Deepset , no. I had to find another solution for my problem because MC team never answered and the bug was never fixed.. or at least not while I was working on that.Arnulfo
Q
0

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.

Quieten answered 7/3, 2021 at 15:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.