I'm new with ASP.NET Web API's and I'm trying to write an API method that will send emails.
This is my sendEmail controller:
[Route("sendemail")]
[HttpPost]
public bool SendEmail(EmailObj email)
{
var To = email.sendTo;
var Subject = email.subject;
var Message = email.message;
...
}
However, whenever I test it using postman, the object sent is null. This is how my json object is built in postman:
{
"subject": "Test Message",
"message": "this is a test",
"sendTo": "sam@test.com"
}
I make sure that the type is marked as JSON on postman and tried formatting it in different ways, but it doesn't seem to work. The API recieves the email object but is always null.
Here's a screenshot of my postman in case I'm missing something.
Any help is appreciated.
Edit: Already tried adding "[FromBody]" and adding "email: {}" to the json but it doesn't work.