title: POST request body cannot contain chinese characters in Java
body: <p>I am using Hibernate and GSON to retrieve data as an object in Java, and create a <code>.toString</code> method via GSON in the POJO to make JSON string. Now I need to use this JSON as a request body to send a POST request to a web service.</p>
  
  <p>The problem is that if the JSON contains any chinese character, it will not work. It complains the chinese name field is incorrect. I checked and there are no spaces in the chinese string, and the <code>.length()</code> of that is exactly the number of characters.</p>
  
  <p>I also tried to copy the whole JSON and paste it to Postman to make the POST request. It will work. How come it does not work in my Java code but works in Postman? Below is how I create the POST request.</p>
  
  <pre><code>RequestConfig requestConfig = RequestConfig.custom()
                  .setConnectionRequestTimeout(CONNECTION_TIMEOUT)
                  .setConnectTimeout(CONNECTION_TIMEOUT)
                  .setSocketTimeout(CONNECTION_TIMEOUT)
                  .build();
  CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build();
  
  StringBuilder entity = new StringBuilder();
  entity.append(myJsonFromPojo);
  
  HttpPost post = new HttpPost(uri);
          post.addHeader("content-type", "application/json");
          post.addHeader("Content-Type", "charset=UTF-8");
          post.addHeader("Accept", "*/*");
          post.addHeader("Accept-Encoding", "gzip,deflate");
          post.addHeader("Authorization", "Bearer " + token);
          post.setEntity(new StringEntity(entity.toString()));
  
  response = httpClient.execute(post);
  
  </code></pre>