The woocommerce_rest_cannot_view Error in WooCommerce REST API
When you encounter a {"code":"woocommerce_rest_cannot_view","message":"Sorry, you cannot list resources."} response from the WooCommerce REST API, it is almost never an SSL issue or a problem with your Consumer Key format. That error code specifically indicates an authentication failure where the server has determined that the current request lacks valid credentials to access the requested endpoint.
In the scenario described, the user has generated a Consumer Key and Secret but is hitting a 401 Unauthorized status. The root cause lies in how WooCommerce handles API authentication versus standard web browsing. You cannot simply paste the URL http://www.my-domain.com/wp-json/wc/v1/products/ into a browser to verify connectivity if you are using API credentials. Web browsers handle HTTP Basic Authentication differently than your application, and without explicit headers or cookies, they often fail to send the necessary authentication data automatically when accessing public-facing resources that require specific keys.
The most common pitfall for developers new to WooCommerce is treating the Consumer Key like a username. To resolve this, you must pass both the Consumer Key and the Consumer Secret in every request. In an Android app or any HTTP client, this requires constructing a Authorization header using the Basic authentication scheme. You need to base64 encode the string consumer_key:consumer_secret.
Here is how the logic works technically:
- Concatenate your Consumer Key and Secret with a colon separator (e.g.,
ck_abc123:cs_xyz789). - Base64 encode that combined string.
- Prefix it with
Basicin the HTTP header.
Your request must look like this:
GET /wp-json/wc/v3/products HTTP/1.1
Host: www.my-domain.com
Authorization: Basic Q0tfYWJjMTIzOkNTXHl6fzg5
Content-Type: application/json
(Note: The version in the URL path should match your installed plugin version; wc/v2 is common, but wc/v3 is the current standard for many installations.)
If you are testing this manually via a browser or Postman, ensure you are not relying on automatic cookie sessions. WooCommerce separates admin login sessions from API authentication contexts. Even if you are logged into the WordPress dashboard, that session token does not automatically grant access to REST endpoints protected by consumer keys unless specifically configured to do so, which is generally discouraged for security reasons.
Regarding the SSL concern: The error message woocommerce_rest_cannot_view is distinct from SSL handshake errors (which usually result in a connection timeout or an HTTPS warning). If your server does not have an SSL certificate installed and you are attempting to connect via https, the connection will fail before authentication even occurs. However, if you are accessing the site via http:// (as shown in the error example), the lack of SSL is not the direct cause of the 401 error. That said, relying on HTTP for API traffic exposes your Consumer Secret to potential interception in transit. For a production environment or any app handling sensitive data, you must install an SSL certificate and force https traffic.
Using the PHP Client Library is not required just to fix authentication; that library is designed for server-to-server integration, often using WooCommerce's own servers as the endpoint (e.g., woocommerce.com). If you are building a native Android app or a custom backend, you should use your preferred HTTP client (such as Retrofit in Android) and implement the header logic directly.
One final check on your implementation: verify that your Consumer Key is set to "Read/Write" permissions if you intend to modify data, though listing resources usually only requires "Read". If you recently generated a new key, ensure it hasn't been revoked or restricted by scope settings in the WooCommerce admin panel under WooCommerce > Status > Tools > REST API.
Once the Authorization header is correctly formatted with both credentials and your endpoint URL points to the correct version of the API, the 401 error will resolve into a successful JSON response containing your product data.