My Mautic version is: 4.1.2
My PHP version is: 7.4.30
My Database type and version is: mysql 8.0.30
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 “ 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:
"name": "test API email",
"subject": "API test email",
"customHtml": "<p>My HTML</p>",
These errors are showing in the log:
lists: This value is not valid
Steps I have tried to fix the problem:
Literally, everything I can think of, plus:
- Every relevant topic in this forum
Would anyone be willing to share the JSON payload they use for a POST to create a segment/list email?
Still having this problem and finding solutions on this forum and the net very limited.
Any help appreciated!
@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.
@entrepositive Did you find out any solution?
@joeyk Did you try to create an email using an API call? I will recommend you to just try. I think it is a bug in API.
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.
and have a safe journey.
Sorry can’t clean this up, I’m in a car, but try this:
(make sure you use the right template name)
whisper this payload:
'fromName' => $fromName,
'name' => $emailName,
'subject' => iconv_mime_decode($emailSubject,0,"UTF-8"),
'language' => 'de',
'template' => 'blank',
'emailType' => 'list',
'isPublished' => 0,
'customHtml' => $htmlTemplate,
'plainText' => '',
'createdBy' => 1,
'createdByUser' => 'Joey Keller',
'category' => null,
'useOwnerAsMailer' => 0,
'lists' => 10,
'publishUp' => date("Y-m-d").' 14:00:00',
'publishDown' => date("Y-m-d").' 18:00:00',
'unsubscribeForm' => null
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:
"subject": "A very catchy subject",
"fromName": "My Name",
"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>",
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.
Thank you very much @joeyk
That will be really helpful if you post request body here.
Thanks for sharing your findings @entrepositive .
Updated my response above. Thanks for the reminder. @abdulwahab
This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.