Here’s my problem: using a clean installation of Debian v13 in a virtual machine, I installed WordPress and the MainWP plugin via WP-Cli.
I configured it (permalinks other than PLAIN, and removed other unnecessary plugins).
I created an API v2 key in the REST API section with only Read permissions.
In Postman, I retrieved the MainWP REST API v2 collection and selected the “Get Sites” endpoint.
I filled in the requested fields (the site link and the API key).
However, when I executed the request, I only got a 401 error with the message “The API key provided does not have read permissions.”
I didn’t understand where I went wrong. I spent all day looking for a solution, but without success, the problem just persisted.
Ask me if you want information, since it’s only local, the data doesn’t matter to me.
Just to test it out, can you see if you will get the same 401 error when this API key has both Read and Write permissions?
When you open http://mainwp.zindex.test/wp-json/ directly in your browser, do you see WP REST index JSON?
If there is some kind of a block in place, you will see a message similar to this
one: {"code":"rest_cannot_access","message":"DRA: Only authenticated users can access the REST API.","data":{"status":401}}
After extensive research into these blocking (401) issues, I finally installed SSL on the local server, and by some miracle, API requests finally work.
Surprisingly, MainWP requires SSL to match API keys to permissions, and I couldn’t find anything in the documentation that specifies what’s required for command-line configuration.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
WordPress® is a registered trademark of the WordPress Foundation, and WooCommerce® is a registered trademark of WooCommerce, Inc. MainWP is an independent product and is not affiliated, associated, or endorsed by the WordPress Foundation, WooCommerce, Inc., or Automattic Inc., except where noted under the Jetpack® API and Trademark License Agreement. All product names, logos, and brands are property of their respective owners and are used for identification purposes only.