title: Sending json string to C# web service from android
body: <p>I am triying to comunicate my android application with a json c# web service
  I got to retrieve a json object from the web service but I am failing sending a json object to the web service.</p>
  
  <p>Here is my web service code</p>
  
  <pre><code> [WebMethod]
      public void recibePosicion(string json_cad)
      {
  
          JavaScriptSerializer jss = new JavaScriptSerializer();
          Posicion nueva_posicion = jss.Deserialize&lt;Posicion&gt;(json_cad); 
          PosicionDAO posicion_dao = new PosicionDAO();
          posicion_dao.InsertaPosicion(nueva_posicion);
  
  
      }
  </code></pre>
  
  <p>and here is my andorid 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("http://10.0.2.2:1218/JSON.asmx/recibePosicion");
               post.setHeader("Accept", "application/json");
               post.setHeader("Content-type", "application/json");
  
  
               json.put("idPosicion", "-1");
               json.put("x", "100");
               json.put("y", "200");
               StringEntity se = new StringEntity( json.toString(), HTTP.UTF_8);  
               se.setContentType("application/json");
               post.setEntity(se);                                  
  
              HttpResponse getResponse = client.execute(post);
  
              final int statusCode = getResponse.getStatusLine().getStatusCode();
  
              if (statusCode != HttpStatus.SC_OK) { 
                 Log.w(getClass().getSimpleName(), "Error " + statusCode + " for URL " + url); 
                 return null;
              }
  
  
  
  
  
           }
           catch(Exception e)
           {
               e.printStackTrace();
               System.out.println("Cannot Estabilish Connection");
           }
  </code></pre>
  
  <p>I get statuscode 500.
  Instead if i change the web method to </p>
  
  <p>public void recibePosicion()</p>
  
  <p>I get to call the service but i don´t i don´t know how to get the json data.</p>
  
  <p>Please i would apreciate any tip to resolve that issue.</p>
  
  <p>Thanks.</p>