I’m trying to create a new email, but getting an error. This is the curl call:
$curl = curl_init();
echo '.init.';
// Set some options - we are passing in a user agent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "https://".$loginname.":".$password."@".$siteurl."/api/emails/new",
CURLOPT_USERAGENT => 'Mautic Email Connector',
CURLOPT_POST => 1,
// posting the payload
CURLOPT_POSTFIELDS => array(
'fromName' => $fromName,
'name' => $emailName,
'subject' => iconv_mime_decode($emailSubject,0,"UTF-8"),
'language' => 'de',
'template' => 'blank-grapejs',
'emailType' => 'list',
'isPublished' => 0,
'customHtml' => $htmlTemplate,
'plainText' => '',
'createdBy' => 1,
'createdByUser' => 'Auto',
'category' => null,
'useOwnerAsMailer' => 0,
'lists[]' => 10,
'publishUp' => date("Y-m-d").' 16:00:00',
'publishDown' => date("Y-m-d").' 18:00:00',
'unsubscribeForm' => null
)
));
$response = curl_exec($curl);
I’m getting this error all the time:
mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: “Type error: Argument 2 passed to Mautic\CoreBundle\Helper\ArrayHelper::getValue() must be of the type array, null given, called in /var/www/html/mautic/plugins/GrapesJsBuilderBundle/Model/GrapesJsBuilderModel.php on line 73” at /var/www/html/mautic/app/bundles/CoreBundle/Helper/ArrayHelper.php line 27 {“exception”:"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Type error: Argument 2 passed to Mautic\CoreBundle\Helper\ArrayHelper::getValue() must be of the type array, null given, called in /var/www/html/mautic/plugins/GrapesJsBuilderBundle/Model/GrapesJsBuilderModel.php on line 73 at /var/www/html/mautic/app/bundles/CoreBundle/Helper/ArrayHelper.php:27)"}
/mautic/plugins/GrapesJsBuilderBundle/Model/GrapesJsBuilderModel.php on line 73
is:
$customHtml = ArrayHelper::getValue('customHtml', $this->requestStack->getCurrentRequest()->get('emailform'));
It’s driving me crazy, where do I make a mistake?