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 :
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:
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.
Make sure you have given Read/Write Access to the user and also check your .htaccess file in the root directory. Try using this code in .htaccess file
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I also faced same issue, i tried in Postman, PHP, NodeJs everthing, almost spend 2 days but no output, finally started getting response after putting a slash at the end of the URL,
I mean,
Initially i was using https://example.com/wp-json/wc/v3/products?consumer_key=ck_XXXX&consumer_secret=cs_XXXX but change it to like this https://example.com/wp-json/wc/v3/products/?consumer_key=ck_XXXX&consumer_secret=cs_XXXX (Just put a slash before question mark in the start of query string).
In Postman even without set any Authorization settings(Type = No Auth), i started getting responses.
It may be somehow related to my .htaccess, but i feel it would good if i post this solution also here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.