Can I post emails into Mailwizz?

@twisted1919 is there a example API call for this? Like in just plain REST, no php?

Like, what URL do we hit? What parameters it expects? The API examples lack that actual URL itself
 
@Kevin Tao while there are no examples for this case, it is easy to find out.
Generally, we follow the rest rules, meaning that GET will get records, POST will create records, PUT will update and DELETE will delete.

Let's have a look at the action for creating a subscriber:
https://github.com/twisted1919/mailwizz-php-sdk/blob/master/examples/list_subscribers.php#L59
We can see that it is a create action, thus we will make a POST request. We can also see what POST params we have to send, that is: EMAIL / FNAME / LNAME.
We can also see the class is MailWizzApi_Endpoint_ListSubscribers which means we can find it at https://github.com/twisted1919/mailwizz-php-sdk/blob/master/MailWizzApi/Endpoint/ListSubscribers.php (see directory structure) and if we look at the create() method ( https://github.com/twisted1919/mail.../MailWizzApi/Endpoint/ListSubscribers.php#L75 ) we can find the missing piece, the url where the request is made, that is: https://www.your-mailwizz.com/api/lists/[LIST_UID]/subscribers
So to sumarize it, we do a POST request at https://www.your-mailwizz.com/api/lists/[LIST_UID]/subscribers with the EMAIL / FNAME / LNAME params.
 
Hi @twisted1919,

Thanks for the quick reply! It was very helpful (along with the example from https://forum.mailwizz.com/threads/how-can-we-use-api.1455/#post-18607).

It would be helpful for me to know what format your API expects the EMAIL / FNAME / LNAME params?

Right now my request looks like:

Method: POST
URL: [my-mailwizz-server-url]/api/lists/[list-uid]/subscribers
Headers:
content-type: application/json
x-mw-public-key: [my public key]
x-mw-timestamp: 1513478274252​
Body:
{
"email": "kevintaostestemail@email.com",
"fname": "Kevin",
"lname": "Tao"
}
However, the error I get is 422 Unprocessable Entity: "Please provide the subscriber email address." Is my Body formatted correctly? Does it expect JSON or XML param format?

I am using Advanced REST Client (a Chrome extension) to send my requests, and I disabled the API Signature check .
 
Back
Top