sendgrid-nodejs
sendgrid-nodejs copied to clipboard
The to array is required for all personalization objects , and must have at least one email object with a valid email address.
Hello community,
I have this payload in nodeJS and I am using @sendgrid/mail/7.6.1 library (node v.18.15.0):
{
"from": "[email protected]",
"to": "[email protected]",
"templateId": "template-id",
"personalizations": [
{
"to:": [
{
"email": "[email protected]"
}
],
"customArgs": {
"context": "example-string",
"templateId": "template-id"
},
"dynamicTemplateData": {
"confirmUrl": "example-url",
"button": "example-button"
}
}
]
}
When I try to send the email I got the following issue in the response:
field: "personalizations.0.to"
help: "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.to"
message: "The to array is required for all personalization objects, and must have at least one email object with a valid email address."
Based on the response there is a missing to in personalizations array at position 0 but it seems inconsistant because is actually present.
I guess the issue does not reflect the real issue is happening behind the scene.
Do you have any idea what is wrong about it?
Cheers
I solved moving customArgs in the root of the payload:
{
"from": "[email protected]",
"to": "[email protected]",
"templateId": "template-id",
"dynamicTemplateData": {
"confirmUrl": "example-url",
"button": "example-button"
},
"customArgs": {
"context": "example-string",
"templateId": "template-id"
}
}
Actually I did not understand why is not working with the old structure. I leave the issue open in case someone helps to investigate.