1

The WordPress/WooCommerce API is broken on my site: http://example.com/wp-json/wp/v2/posts and http://example.com/wp-json/wc/v2/products both return a blank response.

Running a Python request by

response = requests.get('http://<mysite>.com/wp-json/wp/v2/posts', auth=HTTPBasicAuth(*auth))

gives a response (examined in a debugger) of

{
   ...
   _content: b''
   headers: ... 'content-type': 'text/html' ...
}

According to https://github.com/WP-API/WP-API/issues/2911, the blank response means there is an fatal php error.

Last week I was using the WordPress API to add WC products to my site, with no problems. I believe it stopped working when I installed the WordPress-rest-api plugin, then uninstalled it, after realizing it was not necessary.

I set up a development site as a sanity check and everything worked fine.

Specifically, I want the WooCommerce API to work, but I assume that means the rest API should also work.

We have backups, but there have been some changes since the last backup. Do I have to recreate the site from backup for it to work again?

EDIT: The only error in error_log is

[PHP Deprecated:  Automatically populating $HTTP_RAW_POST_DATA is 
deprecated and will be removed in a future version.
To avoid this warning set 'always_populate_raw_post_data' to '-1' 
in php.ini and use the php://input stream instead.
in Unknown on line 0

which does NOT occur at the same times as my API requests.

  • A completely blank page is usually a fatal error as you said, so the first step would be to look at the error log and see what the error is. If you can restore a complete backup of the code & data from before things broke that's another option. – user66711 Jun 16 '17 at 13:20
0

Uninstalling and reinstalling all plugins revealed the answer, which I recommend as the first step for addressing this sort of problem.

The problem was apparently due to a conflict between WC-Vendors and another plugin which declared the same class WC_Email_Notify_Shipped. So I disabled WC-Vendors, which we weren't using at the time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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