This is a question that has been asked on Stackoverflow several times. But I could not found a solution for my specific scenario. In all those cases, the solution is to save the json data in UTF-8; so that the caller gets a valid Json.
In my case with Spring boot and RestTemplate, I get a Json as a response for a API request I make to a third party server. I have no control whatsoever to change that side.
So, Is there any way that I can make something from myside as the receiving end to fix following issue.?
JsonParseException: Invalid UTF-8 start byte 0x91
Below is how I have coded my request.
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
----
----
HttpEntity<HashMap> request = new HttpEntity(dataMap, headers);
Thank you..!
I got it resolved.
I had to accept the response as a String first and then do the string manipulation accordingly as per the format I want the data to be.
String responseJsonString = restTemplate.postForObject(url, request, String.class);
Hope it might be of help for somebody.