1

Just downloaded wordpress latest, using LAMP (Apache2/MariaDB and PHP8.2) and curling it returns this

curl http://localhost:80/wordpress/xmlrpc.php; echo
XML-RPC server accepts POST requests only.
curl -X POST http://localhost:80/wordpress/xmlrpc.php; echo
<?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>

It seems running. When I use python client

>>> from wordpress_xmlrpc import Client
>>> c = Client('http://127.0.0.1/wordpress/xmlrpc.php', 'wordpressuser', 'wordpressuser69$')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/dist-packages/wordpress_xmlrpc/base.py", line 24, in __init__
    self.supported_methods = self.server.mt.supportedMethods()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1122, in __call__
    return self.__send(self.__name, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1464, in __request
    response = self.__transport.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1166, in request
    return self.single_request(host, handler, request_body, verbose)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1182, in single_request
    return self.parse_response(resp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1354, in parse_response
    return u.close()
           ^^^^^^^^^
  File "/usr/lib/python3.11/xmlrpc/client.py", line 668, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32700: 'parse error. not well formed'>
>>>

The user and password is valid and I am testing in localhost for now but error isnt expected here I think. Do you know what could be the problem? I am using someone else library and it fails at xmlrpc. The library has bugs which I fixed but now its in this xmlrpc error https://github.com/seedgularity/AIBlogPilotGPT. ChatGPT gave me sample code to check if its working or not

from wordpress_xmlrpc import Client

wp = Client('http://localhost:80/wordpress/xmlrpc.php', 'wordpressuser', 'wordpressuser69$')
print(wp.call('system.listMethods'))

but even the client part is giving me errors. Both Client('http://localhost:80/wordpress/xmlrpc.php', 'wordpressuser', 'wordpressuser69$') and Client('http://127.0.0.1:80/wordpress/xmlrpc.php', 'wordpressuser', 'wordpressuser69$') gives me error.

This seemingly valid request also produces error:

curl -X POST http://localhost:80/wordpress/xmlrpc.php -d '<?xml version="1.0"?><methodCall><methodName>system.listMethods</methodName></methodCall>'
<?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>

I also do not see any xmlrpc checkboxes in http://localhost/wordpress/wp-admin/options-writing.php. Afaik, xmlrpc is enabled by default. But still I tried putting this line in define('XMLRPC_REQUEST', true); in wp-config.php file and it breaks, admin page is undisplayable but if i remove this line admin page is displayable.

Could it be related to bad apache2 configuration in /etc/apache2/sites-available/wordpress.conf. This is the content

<VirtualHost *:80>
    ServerAdmin webmaster@your_domain.com
    DocumentRoot /var/www/html/wordpress
    ServerName your_domain.com
    ServerAlias www.your_domain.com

    <Directory /var/www/html/wordpress/>
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

and this is the command issued after writing this. I havent changed anything in conf since I am testing in localhost not VPS where I plan to deploy the website after buying a domain

sudo a2ensite wordpress.conf
sudo systemctl restart apache2
6
  • XMLRPC is quite an old API, is there a reason you didn't use the more modern and feature complete REST API?
    – Tom J Nowell
    Commented Jan 15 at 19:27
  • github.com/seedgularity/AIBlogPilotGPT The plugin uses xmlrpc to upload posts so fixing possible error would be less hassle than rewriting that code in rest api. I will look into rewriting it though if possible
    – Machinexa
    Commented Jan 15 at 19:41
  • from what I can see it makes up a tiny portion and is isolated to post_to_wordpress in orchestrar/gutenberg.py and is covered in warnings that it's for testing only. A version that makes a POST request to /wp-json/wp/v2/post with an application password http header might actually be smaller. Eitherway the chance that this is related to anything Apache is very very low, and there's also a chance your host has blocked XMLRPC queries but since the XMLRPC API replied to tell you your message was malformed that too is unlikely
    – Tom J Nowell
    Commented Jan 15 at 21:44
  • 1
    also noting that I tried your curl command on my own site and it worked just fine. You might also want to check your PHP error log, some of the failure cases for the IXR Message parse method involve missing PHP functions/modules github.com/WordPress/WordPress/blob/master/wp-includes/IXR/…
    – Tom J Nowell
    Commented Jan 15 at 21:47
  • I noticed /wp-json folder is missing as well. I tried installing rest api plugin but it failed, setup ftp server, gave all permissions. Installed and activated the plugin but configuring both JWT or basic authentication failed and curling wp-json gave 404.
    – Machinexa
    Commented Jan 16 at 9:25

1 Answer 1

1

Enabling PHP logging and reading logs showed the problem, thanks to Tom.

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', true );
[16-Jan-2024 09:34:09 UTC] PHP Notice:  PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension. in /var/www/html/wordpress/wp-includes/IXR/c    lass-IXR-message.php on line 48

A simple apt install php-xml fixed it

curl -X POST http://localhost:80/wordpress/xmlrpc.php -d '<?xml version="1.0"?><methodCall><methodName>system.listMethods</methodName></methodCall>' | head
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
<?xml version="1.0" encoding="UTF-8"?>      0 --:--:-- --:--:-- --:--:--     0
<methodResponse>
  <params>
    <param>
      <value>
      <array><data>
  <value><string>system.multicall</string></value>
  <value><string>system.listMethods</string></value>
  <value><string>system.getCapabilities</string></value>
  <value><string>demo.addTwoNumbers</string></value>
100  4361  100  4272  100    89   173k   3709 --:--:-- --:--:-- --:--:--  185k
curl: Failed writing body

Python client also doesn't error now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.