I have written a Jersey rest service which accepts java.util.Map
as input for example
@POST
@Path("validate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String validate(Map<String,String> data) throws Exception
And from UI post Response structure is:
{"data":{"abcd":"5210","two":"5173"}}
Server gives an issue
"SEVERE: MessageBodyReader not found for media type=application/json; charset=UTF-8, type=class java.util.HashMap, genericType=java.util.HashMap<java.lang.String, java.lang.String>."
How do I fix this issue?
Just need to change that put the Map object in a wrapper class like
class MapWrapper {
private Map data;
}
and from Jersey Client send the JSON string of object of Map.