title: Can't get an http JSON response in the post http request
body: <p>I'm try to receive http response in the folowing code:</p>
  
  <pre><code>public void httpRes (){
  try {
      HttpClient client = new DefaultHttpClient();
      String postURL = "http://validate.jsontest.com/";
      HttpPost post = new HttpPost(postURL);
          List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
          params.add(new BasicNameValuePair("user", "kris"));
          params.add(new BasicNameValuePair("pass", "xyz"));
          UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params, HTTP.UTF_8);
          post.setEntity(ent);
          HttpResponse responsePOST = client.execute(post);
          HttpEntity resEntity = responsePOST.getEntity();
          if (resEntity != null) {
              Log.i("RESPONSE",EntityUtils.toString(resEntity));
          }
  } catch (Exception e) {
      e.printStackTrace();
  }}
  </code></pre>
  
  <p>Got an error -</p>
  
  <p>LogCat log:</p>
  
  <pre><code>09-12 21:48:58.099: INFO/RESPONSE(28485): {
          "error": "No JSON to validate. Please post JSON to validate via the json parameter.",
          "validate": false
          }
  </code></pre>
  
  <p>I've tried to receive response from GET requsets - everything was ok, but when i've tried POST request all variety of POST code - I can't get an answer! What is the problem? need help.</p>
  
  <p>I've also tried:</p>
  
  <pre><code>Map&lt;String, String&gt; comment = new HashMap&lt;String, String&gt;();
  comment.put("password", "password");
  comment.put("avatar", "httpssssssss");
  
  String json = new GsonBuilder().create().toJson(comment, Map.class);
  HttpResponse response = makeRequest("http://validate.jsontest.com/", json);
  //Log.w(TAG, EntityUtils.toString(response));
  try {
      HttpEntity entity = response.getEntity();
      InputStream is = entity.getContent();
      String sss= convertStreamToString(is);
      Log.w("SSSSSSSSSSSSSSSSSS", sss);
  } catch (Exception ex) {
      Log.w("Exception exxx", ex);
  }
  public static HttpResponse makeRequest(String uri, String json) {
          try {
              HttpPost httpPost = new HttpPost(uri);
              httpPost.setEntity(new StringEntity(json));
              httpPost.setHeader("Accept", "application/json");
              httpPost.setHeader("Content-type", "application/json");
              return new DefaultHttpClient().execute(httpPost);
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return null;
      }
  
  private static String convertStreamToString(InputStream is) {
  
          BufferedReader reader = new BufferedReader(new InputStreamReader(is));
          StringBuilder sb = new StringBuilder();
          String line = null;
          try {
              while ((line = reader.readLine()) != null) {
                  sb.append((line + "\n"));
              }
          } catch (IOException e) {
              e.printStackTrace();
          } finally {
              try {
                  is.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return sb.toString();
      }
  </code></pre>
  
  <p>So, what is the problem?</p>