Search code examples
xmlhttpcurlpayloadhttpie

Make POST call with XML payload with HTTPie


Is there equivalent way to make this cURL call with HTTPie?

curl -k -d '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wp.getUsersBlogs</methodName><params><param><value>user</value></param><param><value>pass</value></param></params></methodCall>' https://crmpicco.co.uk/xmlrpc.php

I have tried the following without any success:

http --pretty=all --verify=no POST https://crmpicco.co.uk/xmlrpc.php data="<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wp.getUsersBlogs</methodName><params><param><value>admin</value></param><param><value>pass</value></param></params></methodCall>"

I prefer using HTTPie, but in this instance i've had to fallback to cURL.


Solution

  • With HTTPie you use stdin to pass raw request body data, for example:

    PAYLOAD='<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>wp.getUsersBlogs</methodName><params><param><value>admin</value></param><param><value>pass</value></param></params></methodCall>'
    
    echo "$PAYLOAD" | http --verify=no https://crmpicco.co.uk/xmlrpc.php 
    

    Documentation: https://httpie.org/doc#redirected-input