I am sending a POST JSON Request to my application.
POST /CharSetTest/Test HTTP/1.1
Host: localhost:8090
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 1637b92b-5896-4765-63c5-d04ad73ea9f1
{
"SampleRequest": {
"FullName": "関連当"
}
}
My CXF JAXRS Consumer is defined as below.
@POST
@Produces("application/json; charset=UTF-8")
@Consumes("application/json; charset=UTF-8")
public Response testCharSet(@Encoded String jsonBody);
But the Japanese Character (関連当) that I sent as POST request is not encoded and results in some junk characters "é¢é£å½äºè"
Using SoapUI results in "?????" characters.
This Junk characters differs from client to client from where I hit the request. How Could I encode my POST Request ?
The default encoding is UTF-8, and JSON texts that are encoded in UTF-8 are interoperable in the sense that they will be read successfully by the maximum number of implementations; there are many implementations that cannot successfully read texts in other encodings (such as UTF-16 and UTF-32).
(in §3) JSON text SHALL be encoded in Unicode. The default encoding is UTF-8. (in §6) JSON may be represented using UTF-8, UTF-16, or UTF-32. When JSON is written in UTF-8, JSON is 8bit compatible.
Hi, You can manually add the Content-Type header and it will override the generated one. Go into the "Headers" tab for the request and add a new header. Name it "Content-Type" (without the quotes) and set the value to "text/xml; charset=utf-8" (again, no quotes).
Set the content-type to:
"application/json;charset=UTF-8"
when sending the post request in the application you are using. You can find "content-type" in the Header of the URL in that application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With