Posting XML via curl (command-line) without using key/value pairs

Posted by Mathias Bynens on Stack Overflow See other posts from Stack Overflow or by Mathias Bynens
Published on 2010-05-16T19:38:15Z Indexed on 2010/05/16 19:40 UTC
Read the original article Hit count: 616

Filed under:
|
|
|

Consider a PHP script that outputs all POST data, as follows:

<?php var_dump($_POST); ?>

The script is located at http://example.com/foo.php.

Now, I want to post XML data to it (without using key/value pairs) using command line curl. I have tried many variations of the following:

curl -H "Content-type: text/xml; charset=utf-8" --data-urlencode "<foo><bar>bazinga</foo></bar>" http://example.com/foo.php

Yet none of them seem to actually post anything — according to the PHP script, $_POST is just an empty array.

What am I doing wrong here?

© Stack Overflow or respective owner

Related posts about curl

Related posts about post