title: RestSharp POST Object as JSON
body: <p>Here is my class:</p>
  
  <pre><code>public class PTList
  {
      private String name;
  
      public PTList() { }
      public PTList(String name)
      {
          this.name = name;
      }
  
  
      public String getName()
      {
          return name;
      }
  
      public void setName(String name)
      {
          this.name = name;
      }
  
  }
  </code></pre>
  
  <p>and my RestSharp POST Request:</p>
  
  <pre><code>    protected static IRestResponse httpPost(String Uri, Object Data)
      {
          var client = new RestClient(baseURL);
          client.AddDefaultHeader("X-Authentication", AuthenticationManager.getAuthentication());
          client.AddDefaultHeader("Content-type", "application/json");
          var request = new RestRequest(Uri, Method.POST);
  
          request.RequestFormat = DataFormat.Json;
  
          request.AddJsonBody(Data);
  
          var response = client.Execute(request);
          return response;
      }
  </code></pre>
  
  <p>and when I use the httpPost method with the good URI and a PTList object, the front API anwser that "name" is null.
  I think that my PTList object is not serialized as a valid JSON in the request for the API, but can't understand what's going wrong.</p>