WooCommerce API Healthiness

The Autoship Cloud plugin integrates your WooCommerce site with QPilot using the WooCommerce REST API (version 2).

While the Autoship Cloud plugin does not add to, change or modify your site's REST API, it is very important that your site's WooCommerce REST API is enabled and fully functional to ensure a successful connection with QPilot.

If you are experiencing issues connecting Autoship Cloud to QPilot, it's a good idea to test the WooCommerce API to ensure it is accessible and healthy.

Note: The REST API is a feature of WooCommerce and you may test your site's REST API with or without the Autoship Cloud powered by QPilot plugin being active on your site at any time by following WooCommerce's documentation here.

Testing the WooCommerce API

  1. Navigate to WooCommerce > Settings >> Advanced >> REST API
  2. In older versions of WooCommerce, you may need to select "Enable the REST API" and Save Changes before proceeding.

  3. In the REST API tab, add a new API Key with the settings below:

    Description: "Test Key" (or any description you choose)
    User: Select a user who has Administrator User privileges for the Wordpress site
    Permissions: Read/Write
  4. Follow the guide for  Making a Basic Request to test the WooCommerce API with your site.

How QPilot Makes API Requests

GET Request

Used to securely pass Data from WooCommerce to QPilot to keep data synchronized, including:

  • Order Data
  • Product Data
  • Customer Data
  • Tokenized Payment Data

POST Request

Used to securely create WooCommerce Orders when processing a Scheduled Order over WooCommerce REST API

PUT Request

Used to securely update WooCommerce Order data when processing a Scheduled Order over the REST API.
Also used to securely update product availability data for WooCommerce Products and add QPilot data to Reports and Notifications in Wordpress.

Common Error Responses

401 Unauthorized / 403 Forbidden

  1. Check that the WooCommerce API is enabled on the site. This setting is found in the WP Admin under WooCommerce > Settings > API > Enable the REST API.
  2. Check that there is a valid WooCommerce API key for "Autoship - QPilot". The API keys are listed under WooCommerce > Settings > API > Keys/Apps.
    1. If there is no API key for "Autoship - QPilot", follow the guide to Connect Autoship Cloud.
    2. Ensure that the associated user account for this API key is a site administrator with full privileges to manage WooCommerce.
  3. Remove any .htaccess rules which are restricting access to the site. This will be problematic for incoming requests.
  4. Disable any plugins that are blocking access to the site.

400 Bad Request

The 400 error code indicates that the request is invalid, e.g. using an unsupported HTTP method.  

The error is most common with staging sites using an insecure URL ("http" instead of "https"). This is error is documented by WooCommerce's REST API docs here: https://woocommerce.github.io/woocommerce-rest-api-docs/#errors

If this is the case, you may want to ask your hosting provider to enable your staging site to be a secure URL (use " https://mysite.staging.myhost.com" instead of "http"), so you can then connect your site's API without using the secure URL.

404 Error Resources Not Found

The 404 error indicates that the request reached the server, however the information requested was not found.

This error can be caused by a url redirect configured within your site's htaccess or DNS. 
For example: a site's URL is being redirected from a secure "https" url to an insecure "http" url. 

500 Internal Server Error

The 500 error indicates a fatal exception has been thrown on the server. This type of error can be caused by many different types of issues, and the source of the error must be tracked down.

  1. Check the server error log for any obvious errors. Contact your site administrator to correct these errors then try again.
    • A quick find for "500" in your error logs can usually point out the errors preceding the 500 error (usually another plugin)
      autoship 500
      plugin error
  2. De-activate any plugins that may be having errors first; you may want to de-activate all plugins on the site except for WooCommerce. Test the API and activate additional plugins one at a time until the source of the error is found.
  3. Change the current theme to the default Wordpress theme (WP 2017) then test the API. The default Wordpress theme should not produce any errors. 

Healthy Connection Result with Errors Displaying

Sometimes you may see errors appear within a healthy API test response.
See this example screenshot where a 500 error is returned within a successful API test response: 

This means that it is possible to connect with the URLs (the "endpoints") for your site and successfully test your API, but your site is responding to an API request with "other" errors  (for example returning a non-standard error message or one that is not a common API response). 

This does not necessarily mean that the connection with your site is unhealthy or that Autoship Cloud's connection with QPilot is not working. Instead, it means that your site may have errors within its code. Typically, this type of situation is caused when another plugin installed on your site is causing an unexpected or fatal error. 

Suggested Steps to Resolve This Type of Error

  1. Run the "test connection" action again. 
    1. This helps clear any notices and asks QPilot to retest URLs.
    2. In some cases, the error message clears on its own. If so, this could be that the cause of this issue was resolved (with a plugin update for example) and is no longer causing the notice. 
  2. If the error persists, you'll want to debug this as you would any error within Wordpress.
    1. Enable the WP Error log ( https://wordpress.org/support/article/debugging-in-wordpress/ ). 
    2. The Error log can then be used to troubleshoot which file installed on your site might be causing the problematic response to the API Health Check. 
    3. Pro Tip! You may also configure the WP Error Log to not display to customers and provide additional error details.
PHP Warnings and Errors

Sometimes the WooCommerce API can produce PHP error messages in the response instead of properly formatted JSON.

  1. De-activate all plugins on the site except for WooCommerce and then test the API and activate additional plugins one at a time until the source of the error is found.
  2. Change the current theme to the default Wordpress theme (for example, Storefront or the default "2017" Wordpress theme) then test the API. These default themes should not produce any errors. 

Still need help? Contact Us Contact Us