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

SendGrid send mail error: {"errors":[{"message":"Bad Request","field":null,"help":null}]}" #11

Open
ettengererin opened this issue Feb 11, 2022 · 0 comments

Comments

@ettengererin
Copy link

I am trying to make a request to the Sendgrid mail/send api to send an email via javascript.

I am getting the response: {"errors":[{"message":"Bad Request","field":null,"help":null}]}"

For more context, I am using Airtable scripting to write this script.

const SENDGRID_API_KEY = "XXXXXX" // my api key, removed for the public github question
const data = {"personalizations":[{"to":[{"email":"[email protected]","name":"John Doe"}],
"subject":"Hello, World!"}],"content": [{"type": "text/plain", "value": "Heya!"}],
"from":{"email":"[email protected]","name":"Erin Ettenger"},
"reply_to":{"email":"[email protected]","name":"Sam Smith"}};


const sendgridReq = new Request(
    "https://api.sendgrid.com/v3/mail/send",
    {
        method: "POST",
        headers: {"Content-Type": "application/json",
        "Authorization": "Bearer " + SENDGRID_API_KEY},
        body: data
        }
);

const sendgrid_res = await fetch(sendgridReq);
const sengrid_out = await sendgrid_res.json();
console.log(`Sendgrid out: ${JSON.stringify(sengrid_out)}`);

Would love some help debugging this issue! There is no helpful information in the Bad Request error.

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