title: JSON Post Request contains no parameters
body: <p>I have a problem by my json post request. I created a JsonObject and want to post it to the server but the body of the post request which is received by the server contains nothing and I don't know why...</p>
  
  <pre><code>public class ServiceHandler {
      static String response = null;
      public final static int GET = 1;
      public final static int POST = 2;
      String contentType = "application/json";
      public ServiceHandler() {
  }
  
  public String makeServiceCall(String url, int method) {
      return this.makeServiceCall(url, method, null);
  }
  
  public String makeServiceCall(String url, int method, List&lt;NameValuePair&gt; params) {
      try {
          // http client
          DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpEntity httpEntity = null;
          HttpResponse httpResponse = null;
  
          // Checking http request method type
          if (method == POST) {
              HttpPost httpPost = new HttpPost(url);
              // adding post params
              if (params != null) {
                  JSONObject jsonObj = new JSONObject();
                  jsonObj.put("name", "your name");
                  jsonObj.put("message", "your message");
  
                  StringEntity entity = new StringEntity(jsonObj.toString(), HTTP.UTF_8);
                  httpPost.setEntity(entity);
              }
  
              httpResponse = httpClient.execute(httpPost);
          } else if (method == GET) {
              // appending params to url
              if (params != null) {
                  String paramString = URLEncodedUtils
                          .format(params, "utf-8");
                  url += "?" + paramString;
              }
  
              HttpGet httpGet = new HttpGet(url);
              httpResponse = httpClient.execute(httpGet);
          }
  
          httpEntity = httpResponse.getEntity();
          response = EntityUtils.toString(httpEntity);
      } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      } catch (ClientProtocolException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
      return response;
  }
  </code></pre>