I'm trying to autogenerate a campaign draft with MailJet api v3
$tId=829886;
):<mj-raw> {% for products in var:product %} </mj-raw> <p>{%product.name %}</p> <p>{%product.price%}</p> <mj-raw>{% endfor %}</mj-raw>
I also included both [[UNSUB_LINK_IT]] and [[UNSUB_LINK_EN]] because of the locale it_IT
$tId=829886; $products=[ ["name"=>'Product1','price'=>'free'], ['name'=>'Product2','price'=>'1 mil'] ];
$body = [ 'Locale' => "it_IT", 'Sender' => "MisterMailjet", 'SenderEmail' => "s.s***i@***.p**", 'Subject' => "Greetings from Mailjet", 'ContactsListID' => "13", 'Title' => "Friday newsletter".uniqid(), 'EditMode' => 'tool2', 'TemplateID'=>$tId, 'Variables' => [ 'products' => $products ], ]; $response = $mj->post(Resources::$Campaigndraft, ['body' => $body]);
$response = $mj->post(Resources::$CampaigndraftDetailcontent, ['id' => $cId, 'body' => $body]);
but I always getInvalid json input: object ""->"TCampaignDraft" has no property "Variables"
Can someone link or show me an example of a $Campaigndraft or $CampaigndraftDetailcontent where they pass some variables for a loop, I can't seem to find anything online. I'm not sure if it's even possible to pass vars to campaign anymore. Please any help is appreciated
Currently the advanced "Template Language" used for personalization, is only available for so called Transactional messages and not for Campaigns. Thus the /campaigndraft
resource used to create the Campaign won't recognize the "Variables" or "Vars" properties used to declare the variables within an Send API Call.
Indeed in the guide here you would see that
Mailjet Template language is available for transactional messages only.
From what I know there should be a release for Template Language in Campaigns as well, but that would be with the use of Contact Properties instead of Variables.
I hope that helps.