I am working with Spring MVC using JSON objects. while I am tring to send JSON Object from RESTClient, I am getting
HTTP Status 400 - The request sent by the client was syntactically incorrect ().
This is my controller
ObjectMapper mapper=new ObjectMapper();
@RequestMapping(value = "/addTask", method = RequestMethod.GET)
public ModelAndView addTask(@RequestParam("json") String json) throws JsonParseException, JsonMappingException, IOException
{
System.out.println("Json object from REST : "+json);
Task task=(Task) mapper.readValue(json, Task);
service.addService(task);
return new ModelAndView("Result");
}
My request URL : http://localhost:8080/Prime/addTask
My Json Object :
{"taskName":"nothing","taskId":1234,"taskDesc":"nothing doing"}
Also i tried specifying "Content-Type: application/json" in RESTClient but still am getting the same error
GET
shouldn't you request URL behttp://localhost:8080/Prime/addTask?json=%7B%22taskName%22%3A%22nothing%22%2C%22taskId%22%3A1234%2C%22taskDesc%22%3A%22nothing%20doing%22%7D
with thejson
parameter sent in the query string? – PinholeFiddler
(fiddler2.com/fiddler2/version.asp) to check the request. Also post it in the question so others can have a look at it. – Pinhole