title: Sending a Json to a Webservice from android to asp.net
body: <p>im want to send a http post with a json to my webservice. i know the web service is working because im using Postman to test it. </p>
  
  <p>My web service code is : </p>
  
  <pre><code>namespace ProyectoFinal.Controllers
   {
  [Authorize]
  public class HomeController : Controller
  {
      private PatientModelDBContext db = new PatientModelDBContext();
      private RootObjectRepository repo = new RootObjectRepository();
  
      public ActionResult Index()
      {
          ViewBag.Message = "Sistema Medico Integrado";
  
          return View();
      }
  
      public ActionResult About()
      {
          ViewBag.Message = "Your app description page.";
  
          return View();
      }
  
      public ActionResult Contact()
      {
          ViewBag.Message = "Your contact page.";
  
          return View();
      }
      //[HttpPost]
      [AllowAnonymous]
      public ActionResult Insert(string data)
      {
          try
          {
              var recibido = JsonConvert.DeserializeObject&lt;RootObject&gt;(data);
              repo.InsertOrUpdate(recibido);
              repo.Save();
          }
          catch (Exception err)
          {
              return new JsonResult { Data = err.ToString() };
          }
          return new JsonResult { Data = "Eureka" };
      }
  
      public ActionResult EmergencyRoom()
      {
          return View(db.RootObjects.ToList());
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The code in android is : </p>
  
  <pre><code>HttpClient client = new DefaultHttpClient();
      try {
          String SendBookingURL= "http://pruebaproyectosmi.azurewebsites.net/home/Insert?data=";
          HttpPost post = new HttpPost(SendBookingURL);       
          HttpResponse response;
          String klk =  URLEncoder.encode(json, "UTF-8");
  
          StringEntity se = new StringEntity(klk); 
          System.out.println("URL: " + klk);
          se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "POST/"));
          post.setEntity(se);
  
          try {
              response = client.execute(post);
              System.out.println("URL: " + response);
              HttpEntity entity = response.getEntity();
              if(entity != null) {
                  String ResponseSummaryTable = EntityUtils.toString(entity);
                  System.out.println("body" + ResponseSummaryTable);
              }
          }
            catch (Exception e) {
                  e.printStackTrace();
                  Toast.makeText(getApplicationContext(), (CharSequence) e, 3000).show();
              }
         }
              catch(Exception e){
                  e.printStackTrace();
              }      
  </code></pre>
  
  <p>and the error that is giving me is : </p>
  
  <pre><code>I/System.out(17968): body"System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at ProyectoFinal.Models.RootObjectRepository.InsertOrUpdate(RootObject rootobject)\r\n   at ProyectoFinal.Controllers.HomeController.Insert(String data)"
  </code></pre>
  
  <p>When the web service get the json it suppost to return "eureka";</p>