Please tell me what am I doing wrong when sending a request to the server?

HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(postUrl); httppost.addHeader("Content-Type","application/json;charset=UTF-8") StringEntity body = new StringEntity(hashMap.get("JSON").toString()); body.setContentType("application/json; charset=UTF-8"); httppost.setEntity(body); 

and the server recognizes the Cyrillic alphabet as "?????"

  • are you about this? postUrl = " cityonline.com.ua/bid/add " - JVic
  • 3
    StringEntity body = new StringEntity (hashMap.get ("JSON"). ToString (), ContentType.APPLICATION_JSON.withCharset ("UTF-8")); - Sergey
  • my StringEntity does not skip your version of the constructor; it requires either StringEntity (String s, String charset) or StringEntity (String s) For that, you missed this: StringEntity body = new StringEntity (hashMap.get ("JSON"). toString (), "UTF -eight"); and the server sent the desired encoding - JVic

0