Here is my Controller mapping for put request:
@PutMapping("/voteForPostByUser")
public String vote(@RequestParam(value = "postId", required =
true) String postId, @RequestParam(value = "userId", required = true)
Integer userId, @RequestBody Boolean vote) {
BlogPostVoteDTO blogPostVoteDTO = new BlogPostVoteDTO
(postId, userId, vote);
return
this.blogPostService.updateBlogPostVotes(blogPostVoteDTO);
}
When I run the following request from POSTMAN:
http://localhost:8082/microblog/api/voteForPostByUser?postId=5d564a2638195729900df9a6&userId=5
Request Body:
{
"vote" : true
}
I get the following exception
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Cannot deserialize instance of
`java.lang.Boolean` out of START_OBJECT token; nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize instance of `java.lang.Boolean` out of START_OBJECT token\n
at [Source: (PushbackInputStream); line: 1, column: 1]",
"trace":
"org.springframework.http.converter.HttpMessageNotReadableException: JSON
parse error: Cannot deserialize instance of `java.lang.Boolean` out of
START_OBJECT token; nested exception is
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
deserialize instance of `java.lang.Boolean` out of START_OBJECT token\n
at [Source: (PushbackInputStream); line: 1, column: 1]\r\n\tat
I is probably something simple, but I don't get what am I missing ?