I wanted to write a small and simple REST service using Spring Boot. Here is the REST service code:
@Async
@RequestMapping(value = "/getuser", method = POST, consumes = "application/json", produces = "application/json")
public @ResponseBody Record getRecord(@RequestBody Integer userId) {
Record result = null;
// Omitted logic
return result;
}
The JSON object I sent is the following:
{
"userId": 3
}
And here is the exception I got:
WARN 964 --- [ XNIO-2 task-7] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not deserialize instance of java.lang.Integer out of START_OBJECT token at [Source: java.io.PushbackInputStream@12e7333c; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token at [Source: java.io.PushbackInputStream@12e7333c; line: 1, column: 1]