title: C# WebRequest POST returns 500 internal server error
body: <p>I want to submit xml via postbody to a web service, but am getting a 500 Error from the <code>GetResponse()</code> method. </p>
  
  <p>Here is my snippet:</p>
  
  <pre><code>WebRequest request = WebRequest.Create(URL);
  request.Method = "POST";
  request.ContentType = "application/xml";
  request.Credentials = new NetworkCredential("UserName", "Pass", "Domain");
  
  byte[] body= Encoding.UTF8.GetBytes(myXML);
  request.ContentLength = body.Length;
  
  request.GetRequestStream().Write(body, 0, body.Length);
  
  WebResponse response = request.GetResponse(); //500 response
  </code></pre>
  
  <p>Does anyone know why the server is responding with this error? Am I providing all the needed headers? I have confirmed that the service works through a REST Client Console, but can't seem to <code>POST</code> to it via code. </p>