Sending a transactional email through the v3 API I get a bad request if I do not include content. The API documentation states that I don't need to if I have a template with content and a subject line (which I do). As I've passed the template ID I would expect a status code of 200.
I think the text content is ignored but I'm not certain. Anonymised API calls below.
Bad request:
{"from":{"email":"[email protected]"},"subject":"Hello World","personalizations":[{"to":[{"email":"r
[email protected]"}]}],"template_id":"d6a75e38-41cf-438b-904c-XXXXXXXXXXXX"}
Good request:
{"from":{"email":"[email protected]"},"subject":"Hello World","personalizations":[{"to":[{"email":"r
[email protected]"}]}],"template_id":"d6a75e38-41cf-438b-904c-XXXXXXXXXXXX","content":[{"type":"text/plain","value":"Textual content"}]}
API docs state:
If you use a template that contains content and a subject (either text or html), you do not need to specify those in the respective personalizations or message level parameters.
Thanks for letting us know, we will look into it.
@RyanONeill1970 What was the error message you received?
Http status code of BadRequest but no errors filled out in the error collection.
Just confirmed that this error occurs when directly posting to the Send Mail API (bypassing the client).
I have also captured the exact response which is;
{"errors":[{"message":"The content parameter is required. There must be at least one defined content block. We typically suggest both text/plain and text/html blocks are included, but only one block is required.","field":"content","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content"}]}
I was able to reproduce and I'm now checking with our team to find out if it's a bug and if so, to put in a request for a fix.
@RyanONeill1970,
We have determined that this is an issue regarding the API. Please submit a ticket to https://support.sendgrid.com to track.
Thanks!
same issue here
Will not be using send grid in our service due to not being able to set it up successfully!
Hi @uknowmeright,
What version of the SDK are you using?
With the latest version, here is an example that may help.
With Best Regards,
Elmer