I have to send JSON to the rest end service which is built using spring boot. I am not getting what I am doing wrong. Here is the code
@RestController public class EmailWithTemplate
{
@RequestMapping(value="/create-template",method=RequestMethod.GET)
void CreateTemplate(@RequestBody EmailTemplate emailtemplate)
{
System.out.println(emailtemplate.getName());
}
}
public class EmailTemplate
{
private String name;
private String body;
//private String[] values;
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
public void setBody(String body)
{
this.body=body;
}
public String getBody()
{
return body;
}
}
Plus I have added jackson dependency also in the pom.xml
file.
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
After starting the tomcat server when I hit:
localhost:8080/create-template/{"name":"Test", "body":"Test body"}
This is shown in the browser:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Jan 29 01:58:00 IST 2016 There was an unexpected error (type=Not Found, status=404). No message available