0

属性を含むトランザクション メールを送信しようとしましたが、Sendinblue API は

400 Bad Request {"code":"invalid_parameter","message":"attributes are not valid"}

Sendinblue のドキュメントでは、json オブジェクトと set メソッドも使用するように指示されています。

/**
     * 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;
    }

以下に、メールを送信するためのコードを示します。例を使用します。

$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;
}

メールテンプレートに属性がありました ( %FNAME%など)。

属性を含めないとうまくいきます。

4

1 に答える 1