title: RestSharp Usage
body: <p>Recently I was using <a href="http://restsharp.org/" rel="nofollow noreferrer">RestSharp</a> to consume my Restful Resouce. and expected exchanging data with JSon between server and client. Below is my C# code.</p>
  
  <pre><code>var client = new RestSharp.RestClient();
  var request = new RestRequest(sUrl,Method.POST);
  request.RequestFormat = DataFormat.Json;
  request.Timeout =  TIME_OUT_MILLISECONTS ;
  request.AddHeader("Content-Type", "application/json");
  request.AddBody(new { appID = sAppId, loginName = sUserName, password=sPassword });
  var response = client.Execute(request);
  string s=response.Content;//It is always XML format.
  </code></pre>
  
  <p>The result is not what I expected for(Json data format), although I had set the <code>RequestFormat Json</code> and add Http header <code>Content-Type</code>. So I decided to use the .Net Reflector to found out What happened in the RestClient.Execute method. Here is the code of the method.</p>
  
  <pre><code>public RestClient()
      {
          ...
          this.AddHandler("application/json", new JsonDeserializer());
          this.AddHandler("application/xml", new XmlDeserializer());
          this.AddHandler("text/json", new JsonDeserializer());
          this.AddHandler("text/x-json", new JsonDeserializer());
          this.AddHandler("text/javascript", new JsonDeserializer());
          this.AddHandler("text/xml", new XmlDeserializer());
          this.AddHandler("*", new XmlDeserializer());
          ...
      }
  </code></pre>
  
  <p>I have some questions about it:</p>
  
  <ol>
  <li><p>As the RestClient adds many kinds of <code>Content-Type</code> into the HttpWebRequest. Is it right way to build a Request? And I think Maybe that is the reason why Response.Content always XML. </p></li>
  <li><p>I don't know why the RestClient needs to build a <code>HttpWebRequest</code> like that. Any meaning to do that?</p></li>
  <li><p>If we specified both JSon and XMl message format in a Http Request, which one works finally? Is it allowed?</p></li>
  </ol>
  
  <p>Thanks. Have a good day.</p>