Node API to create a subscriber (Only POST requests allowed for this endpoint)

SoftTimur

Member
(* I understand that node-mialwizz is not your library, but your experience with PHP SDK may help *)

I tried to use the following code to create a new subscriber `aoxiang.paris.new@gmail.com` (I'm sure it does not exist in the list):

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

const subscribers = new ListSubscribers(config);

function createSubscriber() {
    const userInfo = { EMAIL: "aoxiang.paris.new@gmail.com", TRANSACTIONAL_REMINDERS: "YES" };
    subscribers.create({
        listUid: "en804x0lnrf1f",
        data: userInfo
    }).then(result => {
        console.log('Subscriber created:', result);
    }).catch(err => {
        console.error('Error:', err);
    })
}

createSubscriber();

It returned

```
Error: {
status: 'error',
error: 'Only POST requests allowed for this endpoint.'

}
```

Does anyone know what's the correct way to create a new subscriber by API in node?
 
Last edited:
Contact the library author, ask them if they know of any issue. As far as we're concerned, there's no problem creating subscribers via API.
 
Back
Top