使用POST和GET时出现WooCommerce Rest API错误

in there i try to use api customers from woocommerce, when i try to use it i always get response : url : http://example.com/wp-json/wc/v1/customers

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


{
  "code": "woocommerce_rest_authentication_error",
  "message": "Invalid Signature - provided signature does not match.",
  "data": {
    "status": 401
  }
}

and sometime :

and for create :

{
  "code": "woocommerce_rest_cannot_create",
  "message": "Sorry, you are not allowed to create resources.",
  "data": {
    "status": 401
  }
}

what should i do ?

i already add the key :

here

or i only can have 1 key ? : here

or i need to update one of the script ?

hope, someone can help me to resolve my problem

I have encountered this exact issue, however I have good and bad news from my experience, sometimes the API would shut me out when I had made literally no changes, sometimes rebooting the NGINX server would fix this.

At the moment my connection with postman and OAuth 1.0 yields the following;

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

With that our of the way:

  1. Ensure the 'Type' is set to OAuth 1.0 in postman.
  2. Ensure your URL is correct, (http, or https).

As I said above, I never managed to keep mine stable, and it would drop out without changing a single thing.

How I solved this was by using 'Basic Auth', Username your_ck, password your_cs. I believe that you need to be using SSL to use Basic Auth but setting up SSL isn't a big deal so it was definitely worth it.

If you do find out why OAuth 1.0 is failing i'd love to hear.

EDIT: There are many examples of people with this issue example with image may help you. But it seems most people settle for Basic Auth.