Skip to content
New issue

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

The to array is required for all personalization objects , and must have at least one email object with a valid email address. #1425

Open
alessandroperetti opened this issue Jan 16, 2025 · 1 comment

Comments

@alessandroperetti
Copy link

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

@alessandroperetti
Copy link
Author

alessandroperetti commented Jan 16, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant