title: RestSharp issues when sending SOAP style Request
body: <p>I recently implemented RestSharp instead of using plain old HTTP client in .NET Core.  This was too help with some OAuth1 authentication problems and it worked great.  </p>
  
  <p>However, one requirement I need to support is now broken - a call to an old version of NAV that still uses a SOAP envelope and XML.</p>
  
  <p>My RestSharp request is built like this (partially redacted):</p>
  
  <pre><code>var request = new RestRequest(transmission.Url.PathAndQuery, Helper.GetRestSharpMethod(transmission.Method), dataType);
  
  request.AddParameter("text/xml", body, "text/xml", ParameterType.RequestBody);
  </code></pre>
  
  <p>Where dataType is Datatype.Xml and body is my soap envelope as XML text.  I've tried "application/xml".  I've also tried using request.AddBody and request.AddBodyXml - but they just caused more issues.</p>
  
  <p>The endpoint (which we know works with the old request) returns an issue with being unable to read data from inside the SOAP envelope (which again we know is there, because it's in the parameters of the request).</p>
  
  <p>Can anybody suggest any ways of fixing this issue and still using rest sharp?  Or is this not really intended to be supported, and I'd be better off using plain HTTP Client for this specific part?</p>
  
  <p>Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>Concerning the old code, SOAP envelope text is identical.  The difference is that instead of using RestSharp request.AddBody(), I built standard HttpRequestMessage, then set the HttpContent as <code>new StringContent(content)</code></p>
  
  <p>This was sent using standard .NET Core httpclient</p>
  
  <pre><code>var response = await client.SendAsync(request);
  </code></pre>