2

I'm trying to send a campaign to a dynamic list segment based on a custom numeric merge field (GMT_OFFSET, in this case) but the code below yields the following error from the MailChimp API:

"errors" => [
    0 => [
      "field" => "recipients.segment_opts.conditions.item:0"
      "message" => "Data did not match any of the schemas described in anyOf."
    ]
]

My code, using drewm/mailchimp-api 2.4:

$campaign = $mc->post('campaigns', [
    'recipients' => [
        'list_id' => config('services.mailchimp.list_id'),
            'segment_opts' => [
                'conditions' => [
                    [
                        'condition_type' => 'TextMerge',
                        'field' => 'GMT_OFFSET',
                        'op' => 'is',
                        'value' => 2,
                    ],
                ],
                'match' => 'all',
            ],
        ],
    ],
    // Cut for brevity
];

If I am to take the field description literally (see below), the TextMerge condition type only works on merge0 or EMAIL fields, which is ridiculous considering the Segment Type title says it is a "Text or Number Merge Field Segment". However, other people have reported the condition does work when applied exclusively to the EMAIL field. (API Reference)

Imgur

I found this issue posted but unresolved on both DrewM's git repo (here) and SO (here) from January 2017. Hoping somebody has figured this out by now, or found a way around it.

ekad
  • 14,436
  • 26
  • 44
  • 46
oscaralexander
  • 307
  • 2
  • 11

1 Answers1

3

Solved it! I passed an integer value which seemed to make sense given that my GMT_OFFSET merge field was of a Number type. MailChimp support said this probably caused the error and suggested I send a string instead. Works like a charm now.

oscaralexander
  • 307
  • 2
  • 11