title: Android: Http post with parameters not working
body: <p>I need to create an HTTP POST request with parameters. I know there are many examples out there, I have tried using HTTPparams, NameValuePair etc but cant seem to get the correct format for the server. </p>
  
  <p><code>Server Type: REST based API utilizing JSON for data transfer<br>
  Content-type: application/json<br>
  Accept: application/json<br>
  Content-length: 47<br>
  {"username":"abcd","password":"1234"}</code>  </p>
  
  <p>I can pass these headers but I cant seem to pass these params "username","password". Here is my code: </p>
  
  <pre><code>    HttpClient client = new DefaultHttpClient();  
      HttpPost post = new HttpPost("http://www.mymi5.net/API/auth/login");   
      List&lt;NameValuePair&gt; pairs = new ArrayList&lt;NameValuePair&gt;();  
      pairs.add(new BasicNameValuePair("username","abcd"));  
      pairs.add(new BasicNameValuePair("password","1234"));  
      post.setHeader("Content-type", "application/json");
      post.setHeader("Accept", "application/json");
      UrlEncodedFormEntity entity = new UrlEncodedFormEntity(pairs,"UTF-8");  
      post.setEntity(entity);  
      HttpResponse response = client.execute(post);  
  </code></pre>
  
  <p>I tried to debug, but cant see if entity is attached properly or not... What am I doing wrong?</p>
  
  <p>Thanks in Advance.
  Maaz</p>