Ash
Ash

Reputation: 21

Bulk update mailchimp tags via API in BATCH process not working

I am using DrewM Mailchimp API v3. I tried to bulk update tags of my existing contacts using "BATCH" process and it is not working.

Can anyone help me out? Attaching the code snippet for reference.

I tried with both "PUT" and "PATCH". But both are not working.

$Batch     = $MailChimp->new_batch();

$list_id = "123456";
$tagsSelected = ['tagFromAPI 99','tagFromAPI 00'];

$Batch->put("op1", "lists/$list_id/members", [
    'email_address' => '[email protected]',
    'status_if_new'        => 'subscribed',
    'tags'          => $tagsSelected,
    'merge_fields' => [
                     'FNAME' => 'Jish3' ?: '',
                     'LNAME' => 'win' ?: '',
    ]
]);

$Batch->put("op2", "lists/$list_id/members", [
            'email_address' => '[email protected]',
            'status_if_new'        => 'subscribed',
            'tags'          => $tagsSelected,
            'merge_fields' => [
                'FNAME' => 'Lax2' ?: '',
                'LNAME' => 'Sav' ?: '',
     ]
]);

$Batch->put("op3", "lists/$list_id/members", [
            'email_address' => '[email protected]',
            'status_if_new'        => 'subscribed',
            'tags'          => $tagsSelected,
            'merge_fields' => [
                'FNAME' => 'Lenity1' ?: '',
                'LNAME' => 'Lancer' ?: '',
      ]
]);


$result = $Batch->execute();
$MailChimp->new_batch($batch_id);
$result = $Batch->check_status();
echo '<pre>';print_r($result);

Upvotes: 1

Views: 426

Answers (1)

David Edwards
David Edwards

Reputation: 232

This is a little late, but I was running into the same problem. I was submitting tags like:

[{"tagname": "tag"}, {"tagname": "tag"}]

But it needs to be like:

["tags":[{"tagname": "tag"}, {"tagname": "tag"}]]

Upvotes: 0

Related Questions