Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce - woocommerce_rest_cannot_view - Status 401

Tags:

I have generated a consumer key and consumer secret. The website has SSL installed. I have also installed plugins required for JSON and REST services. This is how the url looks like:

https://<url>/wp-json/wc/v1/products 

When I am trying to get(GET) the product details using Basic Auth by using POSTMAN, a Chrome plugin, I get a JSON response like:

{   "code": "woocommerce_rest_cannot_view",   "message": "Sorry, you cannot list resources.",   "data": {     "status": 401   } } 

I have both the READ and WRITE permissions corresponding to the Consumer key.

like image 462
Ram Avatar asked Feb 12 '17 10:02

Ram


People also ask

Could not open WooCommerce authorization page HTTP error 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.

How do I enable REST API in WooCommerce?

To enable the legacy REST API within WooCommerce, go to WooCommerce > Settings > Advanced > Legacy API and tick the Enable the legacy REST API checkbox.


1 Answers

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.

like image 194
Isura Thrikawala Avatar answered Oct 10 '22 16:10

Isura Thrikawala