How do I POST XML data with curl

curl, http, post

Solution

`-H "text/xml"` isn't a valid header. You need to provide the full header:

-H "Content-Type: text/xml" 

Problem

I want to post XML data with cURL. I don't care about forms like said in How do I make a post request with curl. I want to post XML content to some webservice using cURL command line interface. Something like: ``` curl -H "text/xml" -d "<XmlContainer xmlns='sads'..." http://myapiurl.com/service.svc/ ``` The above sample however cannot be processed by the service. Reference example in C#: ``` 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()); } ```

Original source

Related problems