MikelCalvo / node-mailwizz

[UNOFFICIAL] MailWizz API for NodeJS
https://npmjs.org/package/node-mailwizz
ISC License
10 stars 14 forks source link

Node API to update a field of a subscriber #61

Closed chengtie closed 3 months ago

chengtie commented 3 months ago

I tried to use the following code to update TRANSACTIONAL_REMINDERS of aoxiang.paris@gmail.com (whose id is gx661wf91q518):

const { ListSubscribers } = require('node-mailwizz');
const config = {
    publicKey: 'key',
    secret: 'key',
    baseUrl: 'http://mail.mycompany.com/api'
}

const subscribers = new ListSubscribers(config);

function updateSubscriber() {
    const userInfo = { EMAIL: "aoxiang.paris@gmail.com", TRANSACTIONAL_REMINDERS: "YES" };
    subscribers.update({
        listUid: "en804x0lnrf1f",
        subscriberUid: "gx661wf91q518",
        userInfo: userInfo
    }).then(result => {
        console.log('Subscriber updated:', result);
    }).catch(err => {
        console.error('Error:', err);
    })
}

updateSubscriber()

It returned

Subscriber updated: {
  status: 'success',
  data: {
    record: {
      subscriber_uid: 'gx661wf91q518',
      email: '[aoxiang.paris@gmail.com](mailto:aoxiang.paris@gmail.com)',
      ip_address: '74.125.209.68',
      source: 'import',
      date_added: '2023-10-15 08:37:23'
    }
  }
}

However, when i check it on the website of MailWizz, the field TRANSACTIONAL_REMINDERS is still empty.

Does anyone know what's the correct way to update a field of a subscriber by API in node?

chengtie commented 3 months ago

https://forum.mailwizz.com/threads/node-api-to-update-a-field-of-a-subscriber.9134/