I came across a similar situation using a JSON string in a request block recently and using a very similar Spring installation like yours. In my case, I did not specify the String parameter and deserialize it myself, although I let Spring do this:
@RequestMapping(value = "/myService/{id}", method = RequestMethod.POST) @ResponseBody public void myService(@PathVariable(value = "id") Long id, @RequestBody MyJsonValueObject request) { .. }
I was getting HTTP 400 error "The request sent by the client was syntactically incorrect." Until I realized that the default constructor was not @RequestBody MyJsonValueObject , so there were problems deserializing it. However, this problem is presented in this way.
So, if you use POST and objects and get such errors, make sure you have a default constructor ! Add JUnit to make sure you can deserialize this object.
Note. I am not saying that this is the only reason you get this error. In the original case, only String was used (which has a default constructor!), So it is slightly different. But in both cases, it appears that the request URI seems to have been mapped to the correct method, and something went wrong trying to extract the parameters from the HTTP request.
Ben ggulden
source share