I am not able to read json data in post. So far I have been successful is reading string data in get method. Now i am working on POST where I am sending following JSON in body :
{"name": "myname","address":"myaddress"}
I am also sending content-type : application/json header information in the request.
I have downloaded jersey moxy jar and corresponding dependencies. My model class is as following :
@XmlRootElement
public class Mymodel{
@XMLElement
public String name;
@XMLElement
public String address;
}
following is the extract of the resource method
@POST
@Consumes(MediaType.Application_JSON)
public Resource mymethod(Mymodel mode){
System.out.println(mode.name);
}
Am i missing something ? Error I am getting is that media type is not supported(415 Unsupported Media Type). I don't have anything related to json in the web.xml.
As i mentioned in my post above ,I am using jersey moxy jar which actually supports json application type in jersey. So my understanding is that as suggested adding "jersey-media-json-jackson" jar will not add any value, or I need both jackson and moxy jar ?