title: How to send json data to POST restful service
body: <p>I want to call a rest webservice with POST method.Below is the service url and its parameters which I need to pass</p>
  
  <pre><code> Rest Service: https://url/SSOServer/SSO.svc/RestService/Login
  
  Json Object {"ProductCode":"AB","DeviceType":"android Simulator","UserName":"","ModuleCode":"AB_MOBILE","DeviceId":"device-id","Version":"1.0.0.19","CustomerCode":"w","Password":""}
  </code></pre>
  
  <p>Here is my post request code:</p>
  
  <pre><code>public void sendHttpPost() throws ClientProtocolException, IOException{
          HttpPost httpPostRequest = new HttpPost(url + buildParams());
  
          // add headers
          Iterator it = headers.entrySet().iterator();
          Iterator itP = params.entrySet().iterator();
          while (it.hasNext()) {
              Entry header = (Entry) it.next();
              httpPostRequest.addHeader((String)header.getKey(), (String)header.getValue());
          }
  
          HttpClient client = new DefaultHttpClient();
          HttpResponse resp;
  
          resp = client.execute(httpPostRequest);
  
          this.respCode = resp.getStatusLine().getStatusCode();
          Log.i(TAG, "response code: " + getResponseCode());
          this.responsePhrase = resp.getStatusLine().getReasonPhrase();
          Log.i(TAG, "error msg: " + getErrorMsg());
          HttpEntity entity = resp.getEntity();
  
          if (entity != null){
              InputStream is = entity.getContent();
              //Header contentEncoding = resp.getFirstHeader("Content-encoding");
              //Log.i(TAG, "endoding" + contentEncoding.getValue());
              response = convertStreamToString(is);
              //response = response.substring(1,response.length()-1);
              //response = "{" + response + "}";
              Log.i(TAG, "response: " + response);
              is.close();
          }
      }
  </code></pre>
  
  <p>My question is how to add json data to this request??</p>