WooCommerce - woocommerce_rest_cannot_view - Status 401 WooCommerce - woocommerce_rest_cannot_view - Status 401 wordpress wordpress

WooCommerce - woocommerce_rest_cannot_view - Status 401


The 401 error you are getting is because you are using basic auth even though your website is not secure (does not have https).

The solution in postman is to use OAuth 1.0. Just add the consumer key and consumer secret and send the request.


I met same problem.

Here is how I solve it:

require "woocommerce_api"woocommerce = WooCommerce::API.new(  "https://example.com",  "consumer_key",  "consumer_secret",  {    wp_json: true,    version: "wc/v1",    query_string_auth: true  })

The key is query_string_auth: trueyou need to force basic authentication as query string true under HTTPS


Trying to help others:I was struggling with the 401 response while trying to CURL, and also with VBA trying to request as content-type "application/json"However, I was able to pull a valid response by just entering this in my browser address bar:https://mywebsite.com/wp-json/wc/v2/products?consumer_key=ck_blahblah&consumer_secret=cs_blahblah

Following this line of thought, I went back to my VBA app and changed the content type to "application/text" and was able to pull a valid response text with response code 200. Hope this helps someone.