Web Api Method (Fails)

Console Method (Success)

The Console sends the template email.
The Web API returns Status Code Bad Request and the in the Headers a DENY
I used the same api key, template id, and msg params.
Am I totally missing something?
Hi @fireole,
Could you please tell me the error message? You can grab it like this:
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
Thanks!
so the console app works, but in the web api does not.
so I did this in the web api and captured a screenshot

you can see it comes back as BadRequest.
I also put this line in
var test = response.Body.ReadAsStringAsync().Result;
and got this:
{"errors":[{"message":"The content value must be a string at least one character in length.","field":"content.0.value","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content.value"}]}
does this help?
got it.
So I was using a template and not really sending any body text for .AddContact(). So I added this line
mailDto.Body = "test" which will fill the msg.AddContent(MimeType.Text, mailDto.Body);
and then it worked.
the msg.AddContent is mandatory whether you use it or not.
Hello @fireole,
After digging a little deeper, I found that we have not considered the case when you pass an empty string to the Content helper when using a template. We will update the SDK to handle this situation. You can follow that progress here: https://github.com/sendgrid/sendgrid-csharp/issues/419
If you do not have any content you wish to pass, then you do not need to call the msg.AddContent method.
With Best Regards,
Elmer
Most helpful comment
Hello @fireole,
After digging a little deeper, I found that we have not considered the case when you pass an empty string to the Content helper when using a template. We will update the SDK to handle this situation. You can follow that progress here: https://github.com/sendgrid/sendgrid-csharp/issues/419
If you do not have any content you wish to pass, then you do not need to call the
msg.AddContentmethod.With Best Regards,
Elmer