I am getting this response from the server {\"status\":\"true\",\"msg\":\"success\"}
I am trying to parse this json string using Jackson parser library
This error is sometimes (often?) hiding the real problem: a failure condition could be causing the content to be incorrect, which then fails to deserialize.
In my case, today, I was making HTTP calls and (foolishly) omitted to check the HTTP status code before trying to unmarshal the body of the response => my real problem was actualy that I had some authentication error, which caused a 401 Unauthorized
to be sent back to me, with an empty body. Since I was unmarshalling that empty body directly without checking anything, I was getting this No content to map due to end-of-input
, without getting any clue about the authentication issue.
I got this error when sending a GET request with postman. The request required no parameters. My mistake was I had a blank line in the request body.
I had a similar error today and the issue was the content-type header of the post request. Make sure the content type is what you expect. In my case a multipart/form-data
content-type header was being sent to the API instead of application/json
.
The problem for me was that I read the response twice as follows:
System.out.println(response.body().string());
getSucherResponse = objectMapper.readValue(response.body().string(), GetSucherResponse.class);
However, the response can only be read once as it is a stream.
I know this is weird but when I changed GetMapping to PostMapping for both client and server side the error disappeared.
Both client and server are Spring boot projects.