We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I keep on getting the following error when trying to send a transactional email using a template I've setup within sendGrid.
Status code: 400 Error message: message: 'Bad Request', field: null, help: null
I've followed the following example: https://github.com/sendgrid/sendgrid-nodejs#without-mail-helper-class and have developed the following, its probably something simple i've missed or missunderstood.
const subject = 'Email subject'; const templateId = 'myTemplateId'; const sg = require('sendgrid')(myapikey); const request = sg.emptyRequest({ method: 'POST', path: '/v3/mail/send', body: { "personalizations": [ { "to": userEmails, // aray of user emails "substitutions": { "-userName-": userDetails.name, "-productPrice-": productDetails.price, "-productUrl-": productDetails.url, "-productName-": productDetails.name, }, "subject": subject } ], "from": { "email": "myemail", "name": "myname" }, "content": [ { "type": "text/html" } ], "template_id": templateId } }); sg.API(request, function (error, response) { if (error) { console.log('Error response received'); } console.log(response.body.errors); });
Thanks in advance. Tom
The text was updated successfully, but these errors were encountered:
Hello Tom,
I believe you should either remove the content block or add a value.
content
value
You might also try working through this example: https://github.com/sendgrid/sendgrid-nodejs/blob/master/USE_CASES.md#without-mail-helper-class
With Best Regards,
Elmer
Sorry, something went wrong.
@thinkingserious I forgot to update this, I found the issue.
The value of productDetails.price was a number (189.95) once I converted this to a string it now works.
productDetails.price
@tommaton,
Sorry you had to work through that and you are not the first one :(
One of the things we will be adding to the new version of the mail helper is auto-conversion to string.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I keep on getting the following error when trying to send a transactional email using a template I've setup within sendGrid.
Status code: 400
Error message: message: 'Bad Request', field: null, help: null
I've followed the following example: https://github.com/sendgrid/sendgrid-nodejs#without-mail-helper-class and have developed the following, its probably something simple i've missed or missunderstood.
Technical details:
Thanks in advance.
Tom
The text was updated successfully, but these errors were encountered: