title: How do I POST XML data with curl
body: <p>I want to post XML data with cURL. I don't care about forms like said in <a href="https://stackoverflow.com/questions/84619/how-do-i-make-a-post-request-with-curl">How do I make a post request with curl</a>.</p>
  
  <p>I want to post XML content to some webservice using cURL command line interface. Something like:</p>
  
  <pre><code>curl -H "text/xml" -d "&lt;XmlContainer xmlns='sads'..." http://myapiurl.com/service.svc/
  </code></pre>
  
  <p>The above sample however cannot be processed by the service.</p>
  
  <hr>
  
  <p>Reference example in C#:</p>
  
  <pre><code>WebRequest req = HttpWebRequest.Create("http://myapiurl.com/service.svc/");
  req.Method = "POST";
  req.ContentType = "text/xml";
  using(Stream s = req.GetRequestStream())
  {
      using (StreamWriter sw = new StreamWriter(s))
          sw.Write(myXMLcontent);
  }
  using (Stream s = req.GetResponse().GetResponseStream())
  {
      using (StreamReader sr = new StreamReader(s))
          MessageBox.Show(sr.ReadToEnd());
  }
  </code></pre>