title: Android:Posting the data to a webservice using JSON
body: <p>In my code I am posting data to a webservice, but the response I am getting from the webservice is that the specified data is empty.It means that my request is being processed by the webservice, but it's not able the to fetch the corresponding key value.</p>
  
  <p>Code:</p>
  
  <pre><code>Button b1=(Button)findViewById(R.id.button1);
          b1.setOnClickListener(new OnClickListener()
          {
  
              public void onClick(View v) {
                  String gaurav ="new_member="+"[{\"email\":\"sinhagaurav@gmail.com\",\"username\":\"gaurav001\",\"pwd\":\"gaurav001\"}]";  
                  // TODO Auto-generated method stub
                  HttpClient httpclient = new DefaultHttpClient();   
                  HttpPost httppost = new HttpPost("url");  
  
  try{ 
      String d="saurav@gmail.com";
                      JSONObject json = new JSONObject(); 
  
                      json.put("gaurav", gaurav); 
                     // json.put("api_token",settings.getString("api_token", "")); 
                      StringEntity se = new StringEntity(json.toString()); 
                      httppost.setEntity(se); 
                      httppost.setHeader("Accept", "application/json");
                      httppost.setHeader("Content-type", "application/json");
                     se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); 
  
  
                      HttpResponse response = httpclient.execute(httppost);   
                      HttpEntity responseEntity =response.getEntity(); 
  
                      Log.e("USER", EntityUtils.toString(responseEntity).trim()); 
  } catch (UnsupportedEncodingException e11) { 
                      // TODO Auto-generated catch block 
                      Log.e("USER", e11.getMessage()); 
                  } catch (ClientProtocolException e11) { 
                      // TODO Auto-generated catch block 
                      Log.e("USER", e11.getMessage()); 
                  } catch (IOException e11) { 
                      // TODO Auto-generated catch block 
                      Log.e("USER", e11.getMessage()); 
                  } catch (JSONException e11) { 
                      // TODO Auto-generated catch block 
                      e11.printStackTrace(); 
                  }   
  
              }
  
          }
                  );
  </code></pre>
  
  <p>The response from the server is:</p>
  
  <pre><code>12-16 13:59:47.542: E/USER(1257): [{"errorcode":"012"}]
  </code></pre>
  
  <p>List of response from server:</p>
  
  <pre><code>012 You must enter your e-mail address
  013 You must enter your username
  014 The username you chose is already taken
  015 Your e-mail address is invalid
  016 The e-mail address you entered is already taken
  017 You must enter a password   
  025 Your username should have at least 4 characters
  024 Username can only contain letters A-Z and numbers 0-9
  </code></pre>
  
  <p>I am getting a feeling that all is going fine, and that either either my String gaurav; literal is the problem. Her is the string I have to pass as per webservice specifications:</p>
  
  <p>new_member=[{"email":"sinhagaurav@gmail.com","username":"gaurav001","pwd":"gaurav001"}]</p>
  
  <p>I have tried many times but am still getting errorcode:12.</p>