code snippet:
@RequestMapping(method = RequestMethod.POST)//, headers = \"content-type=application/x-www-form-urlencoded\")
public ModelAndView create(@Req
Below worked for me
On server side:
@RequestMapping(value = "test", method = RequestMethod.POST, consumes = {"application/xml", "application/json"})
@ResponseStatus(HttpStatus.OK)
public @ResponseBody
String methodName(@RequestBody EntityClassName entity) {
On client side:
String json = new JSONStringer().object()
.key("key").value("value")
.endObject()
.toString();
StringEntity se = new StringEntity(json);
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
request.setEntity(se);
HttpResponse response = client.execute(request);