I try to send transactionnal emails with attributes but the Sendinblue API's return a
400 Bad Request {"code":"invalid_parameter","message":"attributes are not valid"}
In the Sendinblue documentation, they say to use a json object and the set method's too.
/**
* Sets attributes
*
* @param object $attributes Pass the set of attributes to customize the template. For example, {\"FNAME\":\"Joe\", \"LNAME\":\"Doe\"}
*
* @return $this
*/
public function setAttributes($attributes)
{
$this->container['attributes'] = $attributes;
return $this;
}
Below, my code to send an email, I use their example:
$templateId = 2; // int | Id of the template
$sendEmail = new \SendinBlue\Client\Model\SendEmail(); // \SendinBlue\Client\Model\SendEmail
$sendEmail->setEmailTo(array('example@mail.com')); //for stackoverflow
$sendEmail->setAttributes('{"LNAME":"John","FNAME":"Doe"}');
try {
$result = $apiInstance->sendTemplate($templateId, $sendEmail);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AccountApi->getAccount: ', $e->getMessage(), PHP_EOL;
}
I have had my attributes in my mail template (like %FNAME%).
If I don't include attributes, it works.