sendinblue / APIv3-nodejs-library

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

TypeError: apiInstance.sendTransacEmail is not a function #111

Closed shammahm24 closed 2 years ago

shammahm24 commented 2 years ago

I copied and pasted the sendTransacEmail code from the documentation and got that error in the title. Other functions work with no issues. Is this specific one still working or there are changes to it?

shubhamUpadhyayInBlue commented 2 years ago

Hi @shammahm24

I hope you changed the email and name from dummy values to actual ones.

I tried it just now with 8.2.1 version.

In response I received this: API called successfully. Returned data: {"messageId":"<202108030849.89987092302@smtp-relay.mailin.fr>"}

Please try this out again and let me know if you receive any error.

The script that I used was:


let defaultClient = SibApiV3Sdk.ApiClient.instance;

let apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = 'your-api-key';

let apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();

let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();

sendSmtpEmail.subject = "My {{params.subject}}";
sendSmtpEmail.htmlContent = "<html><body><h1>This is my first transactional email {{params.parameter}}</h1></body></html>";
sendSmtpEmail.sender = {"name":"Shubham Upadhyay","email":"shubham.upadhyay@sendinblue.com"};
sendSmtpEmail.to = [{"email":"shubham.upadhyay@sendinblue.com","name":"Jane Doe"}];
sendSmtpEmail.replyTo = {"email":"shubham.upadhyay@sendinblue.com","name":"John Doe"};
sendSmtpEmail.headers = {"Some-Custom-Name":"unique-id-1234"};
sendSmtpEmail.params = {"parameter":"My param value","subject":"New Subject"};

apiInstance.sendTransacEmail(sendSmtpEmail).then(function(data) {
  console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
  console.error(error);
}); ```

Happy to help!
shubhamUpadhyayInBlue commented 2 years ago

Closing due to no response after waiting for more than 11 days.

shammahm24 commented 2 years ago

Thanks, I will try it out on the project I was working on

On Sat, Nov 6, 2021 at 5:23 AM shubhamUpadhyayInBlue < @.***> wrote:

Closing due to no response after waiting for more than 11 days.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sendinblue/APIv3-nodejs-library/issues/111#issuecomment-962424010, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMS3WEHLR2FLVALMOCEIIVTUKTXZ3ANCNFSM5BOFO6MA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Regards

Tanyaradzwa Shammah Matasva

University of Bridgeport, 21' Global Leader BS Computer Science President -Student Entrepreneur Center (206)830-0732 @. @. @.***