Your software
My Mautic version is: 4.1.2
My PHP version is: 7.4.30
My Database type and version is: mysql 8.0.30
Your problem
My problem is:
[Using n8n / Integromat / Make] I cannot successfully create a new ‘list’ email via the API. I’ve gotten a variety of errors, but I’m currently stuck with either “lists: This value is not valid,” or “[400] Looks like I encountered an error…”
I did successfully create a ‘template’ email from API call, however it loaded with the old email editor, and i cannot edit the email at all.
Here’s the JSON payload I’m sending in the body of the call:
@entrepositive I am also facing this issue. I try to match all values in the List array in the API call but No success. It creates a ‘template’ email (without segment) but for a ‘list’ email (email with segment), it does not works and always gives the same error : lists: This value is not valid.
Because the list is an array. Try to create it accordingly. (Sorry Im travelling cant look up the querry, but I remember. Cost me 2 days and 5 grey hair to figure out.)
@joeyk thanks for the reply. I just tried the array of list as it was mentioned in the documentation. Even I tried to have the same values in Mautic to just test maybe values or ids should be the reason that it is giving the error. But it always gives same error.
There will be some trick in the array of ‘lists’, I am curious how you solved this. When ever you have time just share your findings. It will be a great help from your side.
I did eventually get it working. The lists array input and the customHtml string input both required some experimenting to get working. Hopefully this thread will provide good insight to future digital adventurers like us.
A couple key points:
While lists requires array, an id of desired list should suffice.
customHTML will not work, you must use customHtml.
The string value input to customHtml must be stringified, using JSON.stringify(yourhtml).
publishUp/Down input should be a string following format “YYYY-MM-DD HH:mm:ss” in UTC. Mautic will automatically convert publishUp/Down datetimes to correct timezone
I’ll post a successful request body shortly.
EDIT: Adding my JSON request body:
{
"isPublished": false,
"name": "some-internal-name",
"subject": "A very catchy subject",
"fromAddress": "me@example.com",
"fromName": "My Name",
"useOwnerAsMailer": false,
"publishUp": "2023-08-24 18:30",
"publishDown": "2023-09-01 12:00",
"customHtml": "<!DOCTYPE html>\n<head>\n <title> \n </title>\n </head>\n<body>\n Don't forget to stringify your HTML as one string before including it in the request body.</body>",
"utmTags": {
"utmSource": "myUTMsource",
"utmMedium": "email",
"utmCampaign": "my-campaign",
"utmContent": ""
},
"template": "blank",
"emailType": "list",
"lists": [
1
]
}
Please note that for this example, I removed all the HTML body. I also haven’t played with the date formats for publish up/down yet, nor the utm params, although those are on the agenda today, so perhaps another update will come soon.