title: how to make httpPost call with json encoded body?
body: <p>i am using following code to make an httpPost call but it is returning me 400 bad request
  when i try to give following parameters in "simple rest client" in chrome extension it works fine any one guide me what mistake am i doing here?</p>
  
  <p>Simple rest Client I entered the following:</p>
  
  <p>URL: <a href="http://jon2012.com/api/register" rel="nofollow noreferrer">http://jon2012.com/api/register</a>
  Method: POST
  Headers: No headers, as they are not required
  Data: { "email": "test@example.com", "first_name":"Name" }<img src="https://i.stack.imgur.com/8CYo4.png" alt="enter image description here"></p>
  
  <p>Android Code:</p>
  
  <pre><code>HttpClient client = new DefaultHttpClient();
          HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
          HttpResponse response;
          JSONObject json = new JSONObject();
          try{
              HttpPost post = new HttpPost(url);
              json.put("email", email);
              json.put("first_name", name);
              StringEntity se = new StringEntity( "JSON: " + json.toString());  
              se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
              post.setEntity(se);
              response = client.execute(post);
              /*Checking response */
              /*if(response!=null){
                  InputStream in = response.getEntity().getContent(); //Get the data in the entity
  */
              int statusCode = response.getStatusLine().getStatusCode();
  
          }
          catch(Exception e){
              e.printStackTrace();
             // createDialog("Error", "Cannot Estabilish Connection");
          }
  </code></pre>
  
  <p>any help would be appriciated</p>