javascriptnode.jsmailchimp-api-v3.0

Mailchimp tag API silently failing


I'm calling the Node.js Mailchimp API like so:

const mailchimp = require('@mailchimp/mailchimp_marketing');
const md5 = require('md5');

// ...

const resp = await mailchimp.lists.updateListMemberTags(
  mailchimpListId,
  md5('my@email.com'),
  { tags: [{ name: 'Tag Name', status: 'active' }] }
);

(resp === null) // true

But the response is null, and the tag is not being added to the subscriber.

Any ideas as to why it might be silently failing, and if so, how I can debug it?

(If relevant, this is all being run within an Auth0 Custom Action.)


Solution

  • Thanks to Buck at Mailchimp, I found the solution. Unlike most API calls in the library, updateListMemberTags needs a body wrapper like so:

    const resp = await mailchimp.lists.updateListMemberTags(
      mailchimpListId,
      md5('my@email.com'),
      { body: { tags: [{ name: 'Tag Name', status: 'active' }] } }
    );