title: RestSharp Post a JSON Object
body: <p>I am trying to post the following JSON with RestSharp:</p>
  
  <pre><code>{"UserName":"UAT1206252627",
  "SecurityQuestion":{
      "Id":"Q03",
      "Answer":"Business",
      "Hint":"The answer is Business"
  },
  }
  </code></pre>
  
  <p>I think that I am close, but I seem to be struggling with the <strong>SecurityQuestion</strong> (the API is throwing an error saying a parameter is missing, but it doesn't say which one)</p>
  
  <p>This is the code I have so far:</p>
  
  <pre><code>var request = new RestRequest("api/register", Method.POST);
  request.RequestFormat = DataFormat.Json;
  
  request.AddParameter("UserName", "UAT1206252627");
  
  SecurityQuestion securityQuestion = new SecurityQuestion("Q03");
  request.AddParameter("SecurityQuestion", request.JsonSerializer.Serialize(securityQuestion));
  
  IRestResponse response = client.Execute(request);
  </code></pre>
  
  <p>And my Security Question class looks like this:</p>
  
  <pre><code>public class SecurityQuestion
  {
      public string id {get; set;}
      public string answer {get; set;}
      public string hint {get; set;}
  
      public SecurityQuestion(string id)
      {
           this.id = id;
           answer = "Business";
           hint = "The answer is Business";
      }
  }
  </code></pre>
  
  <p>Can anyone tell me what I am doing wrong? Is there any other way to post the Security Question object ?</p>
  
  <p>Many thanks.</p>