How can I send a regular post request with json'ом ? I just can not understand. Such a thing does not work (it works more precisely, but not json sent, but data):
HttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost(stringUrl); // Request parameters and other properties. List<NameValuePair> params = new ArrayList<NameValuePair>(2); params.add(new BasicNameValuePair("id", "126927462")); params.add(new BasicNameValuePair("message", message)); httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); httppost.setHeader("Content-Type", "application/json"); //Execute and get the response. HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); Can someone fix my code or give an example of how to send json POST'ом ?