Search code examples
phpwordpresshttp-postxml-rpchttpie

Wordpress XML-RPC POST returning -32700 error with php-xml extension installed


I am using HTTPie to do a POST request to my local Wordpress installation with the aim of checking if XML-RPC is available and enabled.

http --verify=no POST https://crmpicco.localhost/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>"

This returns a 200, however the response has a faultCode:

HTTP/1.1 200 OK
Connection: close
Content-Length: 403
Content-Type: text/xml; charset=UTF-8
Date: Fri, 08 Mar 2019 03:18:43 GMT
Server: Apache/2.4.35 (Unix) OpenSSL/1.0.2p PHP/7.2.11
X-Powered-By: PHP/7.2.11

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><int>-32700</int></value>
        </member>
        <member>
          <name>faultString</name>
          <value><string>parse error. not well formed</string></value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

Others with this issue point to having the php-xml extension unavailable, however when I do a php -m | grep -i xml it is showing as installed:

libxml
SimpleXML
xml
xmlreader
xmlrpc
xmlwriter

What am I missing?


Solution

  • I had to fallback to using cURL for this. I'm unsure as to what exactly I was doing wrong with HTTPie or if it has a limitation in this regard, however it worked with cURL with:

    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.localhost/xmlrpc.php