sendinblue / APIv3-nodejs-library

SendinBlue's API v3 Node.js Library
ISC License
101 stars 47 forks source link

Send transactional email BAD REQUEST #28

Closed lobesoftllc closed 6 years ago

lobesoftllc commented 6 years ago

Hi, I'm unable to send a transactional email, does a complete example exists to do that? No template. sib-api-v3-sdk = 6.0.0.

Following the existing example:

        this.sendSmtpEmail.sender = new this.SibApiV3Sdk.SendSmtpEmailSender();
        this.sendSmtpEmail.sender.name = "name";
        this.sendSmtpEmail.sender.email = "account@email.ext";

        this.sendSmtpEmail.replyTo = new this.SibApiV3Sdk.SendSmtpEmailReplyTo();
        this.sendSmtpEmail.replyTo.name = "name";
        this.sendSmtpEmail.replyTo.email = "account@email.ext";

        this.sendSmtpEmail.subject = "subject";

        this.sendSmtpEmail.htmlContent = '<p>test</p>';
        this.sendSmtpEmail.textContent = 'please, use an email agent that support html';

        this.sendSmtpEmail.to = new this.SibApiV3Sdk.SendSmtpEmailTo();
        this.sendSmtpEmail.to.name = "destination@email.ext";
        this.sendSmtpEmail.to.email = "destination@email.ext";

        /*i tried whit this : same error*/
        let body = {"sender":{"name":"nozone","email":def.from},
                    "replyTo":{"email":def.from,"name":"nozone"},
                    "subject":def.subject,
                    "htmlContent":`<p>test</p>`,
                    "textContent":'please, use an email agent that support html',
                    "to":{"email":def.to,"name":def.to}};

            await this.apiInstance.sendTransacEmail(this.sendSmtpEmail); //bad request received
lobesoftllc commented 6 years ago

Found! fields named [name] are.. array! it wasn't clear to me. Sorry.