3

I am using the postman for the check the REST API Call in WooCommerce. When I call the Woocommerce Defaults API. It displays the error like.

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

The above error displays when the Basic Authentication and POST method of Create Customers API.

And when I am Trying to Call the Display products API with the cURL

http://example.com/wp-json/wc/v2/products

Using the GET Methods from postman it will display the following error.

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

It would be great if anyone saving me from this headache. Thanks..

1
  • 1
    Use https authentication in postman, instead of using oAuth1.0 as the authentication options. Use Basic authentication and pass consumer key as the username. And the password should be consumer secret.
    – LumberHack
    Nov 6, 2017 at 11:55

5 Answers 5

1

I got the solution for it. Use the Basic Authentication from the Postman.

Thanks

0

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.

0

For me, it was an authentication issue.

I was using Basic auth for the postman

Just select OAuth 1.0 for authentication type and put the consumer and secret key on the field

Screenshot:

postman-woocommerce-API

-1

if you are using basic auth, be sure that apache is return header authorization, in you http.conf put this SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

-1

Make sure you have given Read/Write Access to the user and also check the .htaccess. Try to paste this code in your .htaccess and check again

# 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
1
  • Please edit your answer, and add an explanation: why could that solve the problem?
    – fuxia
    Jul 27, 2020 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.