Reputation: 31
I am having problems with getting a json contentType through to glassfish server where I have java restful web service setup.
I POST from Node.js with needle :
var options = {
json: true,
headers: {'Content-Type':'application/json'}
}
needle.post(base_url+'priorityList/',priorityList,options, function(err, resp, body){
});
and receive with jersey:
@POST
@Path("/priorityList/")
@Consumes(MediaType.APPLICATION_JSON)
//@Consumes("text/plain")
@Produces(MediaType.APPLICATION_JSON)
public JSONArray priorityList(JSONObject incomingJsonString)throws IOException {
}
and it gives me this error on the glassfish server:
WARNING: StandardWrapperValve[com.mycompany.recommenderenginejava.ApplicationConfig]: Servlet.service() for servlet com.mycompany.recommenderenginejava.ApplicationConfig threw exception
org.codehaus.jackson.map.exc.Unr`enter code here`ecognizedPropertyException: Unrecognized field "{"categories":["golf","banks"]}" (Class com.mycompany.recommenderenginejava.JSONObject), not marked as ignorable
at [Source: org.glassfish.jersey.message.internal.EntityInputStream@4c0db744; line: 1, column: 43] (through reference chain: com.mycompany.recommenderenginejava.JSONObject["{"categories":["golf","banks"]}"])
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
this looks like it should be in correct format, I dint understand, and have tried 1000 things to get it working.
any help is greatly appreciated
Upvotes: 1
Views: 4804
Reputation: 2714
You'll need to post up com.mycompany.recommenderenginejava.JSONObject if you want specific advice but the answer is that the JSON doesn't match the class you're trying to parse it into. The JSON has a field ("categories") that isn't present as a public field or setter in the class definition.
Upvotes: 1