I have created a rest API using Spring boot. I am using JSON as the request and response type. Everything was working fine and I was happy until I tested it will some french words. I want my API to support all languages characters as this application might be used work wide. My JSON looks like below:
{
"highlights": "Adiós",
"language": "FR",
"longDescription": "Adiós",
"name": "Adiós",
"shortDescription": "Adiós"
}
Spring is throwing the below error:
JSON parse error: Invalid UTF-8 middle byte 0x73; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid UTF-8 middle byte 0x73\n at [Source: (PushbackInputStream); line: 2, column: 25]
I am using Java 11 with Spring boot 2.3.1.RELEASE
Edit:
I even tried sending Content-type as application/json; charset=utf-8
and adding same in @PostMapping
consume and produce. But nothing helped.
Edit:
As suggested in the comment I also tried setting below spring property But still didn't work.
server.servlet.encoding.charset=UTF-8
server.servlet.encoding.force-response=true