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
- Navigate to WooCommerce > Settings >> Advanced >> REST API
- In older versions of WooCommerce, you may need to select "Enable the REST API" and Save Changes before proceeding.
- 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
- Follow the guide for Making a Basic Request to test the WooCommerce API with your site.
How QPilot Makes API Requests
Used to securely pass Data from WooCommerce to QPilot to keep data synchronized, including:
- Order Data
- Product Data
- Customer Data
- Tokenized Payment Data
Used to securely create WooCommerce Orders when processing a Scheduled Order over WooCommerce REST API
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
- 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.
- Check that there is a valid WooCommerce API key for "Autoship - QPilot". The API keys are listed under WooCommerce > Settings > API > Keys/Apps.
- If there is no API key for "Autoship - QPilot", follow the guide to Connect Autoship Cloud.
- Ensure that the associated user account for this API key is a site administrator with full privileges to manage WooCommerce.
- Remove any .htaccess rules which are restricting access to the site. This will be problematic for incoming requests.
- 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.
- 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)
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
- Run the "test connection" action again.
- This helps clear any notices and asks QPilot to retest URLs.
- 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.
- If the error persists, you'll want to debug this as you would any error within Wordpress.
- Enable the WP Error log ( https://wordpress.org/support/article/debugging-in-wordpress/ ).
- 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.
- 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.
- 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.
- 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.