WordPress API returns HTML not JSON

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.