title: wp7 - POST http request with parameters in request body using RestSharp
body: <p>I am trying to POST parameters through the request, to a service that returns a JSON object. The service works well for android and iOS. I am trying to get this working for wp7. The service requires the content type to be  'application/json' I have pasted the code that sets up the http request below:</p>
  
  <pre><code>            var client = new RestClient(baseurl);
              var request = new RestRequest();
              request.Resource = "login";
              request.Method = Method.POST;
              request.AddHeader("Accept", "application/json");
              request.AddHeader("content-type", "application/json");         
              request.RequestFormat = DataFormat.Json;
  
              var postData = new Dictionary&lt;string, string&gt;()
              {
                  {"key1",value1},
                  {"key2",value2}
              };
  
              request.AddBody(postData); 
              client.ExecuteAsync(request, response =&gt;
              {
                  var jsonUser = response.Content;
              });
  </code></pre>
  
  <p>The response error I get from the server is an internal server error. Is anything wrong with the code above. I also tried request.AddParameter method but ended with the same result. The code for that is below:</p>
  
  <pre><code>            var client = new RestClient(baseurl);
              var request = new RestRequest();
              request.Resource = "login";
              request.Method = Method.POST;
              request.AddHeader("Accept", "application/json");
              request.AddHeader("content-type", "application/json");         
              request.RequestFormat = DataFormat.Json;
  
              var postData = new Dictionary&lt;string, string&gt;()
              {
                  {"key1",value1},
                  {"key2",value2}
              };
              var json = JsonConvert.SerializeObject(postData);
              request.AddParameter("application/json", json, ParameterType.RequestBody);
              client.ExecuteAsync(request, response =&gt;
              {
                  var jsonUser = response.Content;
              });
  </code></pre>
  
  <p>Is there anything that I am doing wrong in either of the cases? </p>