Reputation: 9722
I'm using a web interface that allows me to post stuff over a cURL request.
A sample post looks like this:
<status>A note</status>
But whenever I try to send this, it seems to not accept the XML
curl http://website.com/update -d '<?xml version="1.0" encoding="UTF-8"?><status>test</status>' -H 'Accept: application/xml' \ -H 'Content-Type: application/xml' -u username:password
I can do any other type of requests, just sending this XML doesn't seem to work, am I doing something wrong here?
Upvotes: 6
Views: 19408
Reputation: 1456
To send data (xml,json,text,etc) using curl
you have to use POST method and add --data-urlencode
parameter, like shown bellow:
curl -X POST http://website.com/update \
--data-urlencode xml="<status>A note</status>" \
-H 'Accept: application/xml' \
-H 'Content-Type: application/xml' \
-u username:password
or
curl -X POST http://website.com/update \
--data-urlencode "<status>A note</status>" \
-H 'Accept: application/xml' \
-H 'Content-Type: application/xml' \
-u username:password
If you want to send via GET i think you have to encode the string before calling curl
command
Upvotes: 7