title: Post XML in body of rest call using Rest Sharp
body: <p>I'm having an issue trying to make a POST using Rest Sharp. I am trying to make a call to a web service that doesn't exactly conform to modern standards and I need to be able to post the request XML in the body of my post.</p>
  
  <p>If I simply do request.AddBody(xmlObject) on the RestRequest object, a parameter called text/xml is added to the request. In this case, I get an error response from the server saying "Exception thrown: Content is not allowed in prolog". This tells me that the server is trying to process the key of the parameter (text/xml=) along with the value.</p>
  
  <p>When I use the REST Console in chrome with the desired xml request in the RAW body field, everything works as expected.</p>
  
  <p>Any ideas on how I could make this work with Rest Sharp?</p>
  
  <p>Edit: Looks like I need to use request.AddFile("name", bytes_to_add, "file_name"). However, when I try to do that, I get an exception ("System.InvalidOperationException: This property cannot be set after writing has started."), which looks like an <a href="https://github.com/restsharp/RestSharp/issues/204" rel="nofollow">issue</a> with RestSharp that was never resolved. I might just have to go with making requests with the HttpWebRequest library.</p>