Tags

, , , ,

Summary

I found that in some cases the WordPress API was returning HTML not JSON. Inspection of the HTML showed that I was being redirected to the login page by Formidable Registration Plugin when basic authentication failed.

Steps to Resolution

The steps to resolution were,

 

  1. Disable all plugins
  2. Install Basic Auth plugin from https://github.com/WP-API/Basic-Auth
    1. You MUST do this because although WordPress 5.0  includes the WP API it DOES NOT INCLUDE BASIC AUTH.
    2. Confusing! Note that it is called “JSON Basic Authentication” in the plugins list not “Basic Authentication”.
  3. Follow the TutsPlus learning journey (don’t test Filters or oAuth because that functionality has changed).
    1. https://code.tutsplus.com/series/introducing-the-wp-rest-api–cms-896
    2. GET resources
    3. POST (create resources)

it is expected that this will succeed. If it does not then you may have issues with URL rewriting in your .htaccess file. Use this fix.

On success,

  1. Activate your plug-ins one-by-one.
    1. After each activation, test an API call using curl or Postman until you find a plugin that is breaking your system.

 

Advertisements