I've posted XML to a server via the command line curl and I've been completely successful. The only option I'm actually setting is the a header to set the content-type to application/xml.
When I turn around and try this in PHP I'm getting a 500 server error.
As far as curl options all I'm setting are as follows:
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
I've even gone so far as to copy and paste the XML output from the PHP application into the command line curl and it works just fine. I've tried various other curl options in different combinations with no luck.
If I had to guess there is some kind of encoding issue that is occurring but I've tried urlencoding the data and I actually get back a bad request instead of the 500.
I'm at a complete loss so if anyone has any ideas I'd love to hear them.
Thanks!
$requestis valid XML, though I would expect a400 Bad Requestfrom that). I don't see any problems with the code you've posted. Is there any other code involved you might add to the question? Or perhaps the XML you're trying to POST?