I believe i have some endpoint issue with my current controller. I'am trying to send an email using JavaMailSender.
The example below works just fine when sending hardcoded string values.
@RequestMapping("/sendhc")
public void sendSimpleMessage() {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo("firstname.lastname@gmail.com");
message.setSubject("subject");
message.setText("text");
emailSender.send(message);
}
I want to be able to make a request with the values instead of the hardcoded string example as shown above. When posting this i get the NullPointerException.
@RequestMapping("/send")
public void sendSimpleMessage(String to, String subject, String text) {
SimpleMailMessage message = new SimpleMailMessage();
message.setTo(to);
message.setSubject(subject);
message.setText(text);
emailSender.send(message);
}
I'm trying POST to localhost:8080/send
, with the following values: (as shown in image above)
{
"to":"email@gmail.com",
"Subject":"New Errand",
"text":"loremloremloremloremlorem"
}
Any suggestions of where I could've gone wrong are much appreciated.