1

when i paste this link

http://localhost/wordpress/wp-json/wc/v2/products?consumer_key=ck_*******************&consumer_secret=cs_********************

it show for me this error message

{"code":"woocommerce_rest_cannot_view","message":"D\u00e9sol\u00e9, vous ne pouvez pas lister les ressources.","data":{"status":401}}

by the way the cosumers key & secret are correct

0

6 Answers 6

2

Here are 2 possible solutions:

  1. Add the following variable in the index.php page of your WordPress installation (Worked for me on my localhost without having to restart the server):

$_SERVER['HTTPS'] = 'on'; //------> Add this line under the line that says: define( 'WP_USE_THEMES', true );

  1. Set the environment variable in the .htaccess file when using Apache:

SetEnv HTTPS on

Sign up to request clarification or add additional context in comments.

Comments

1

Your connection must be throw https and add this lines to your woocommerce init :

{
....
      verifySsl: false,
      queryStringAuth: true
}

every post request require ssl

dublicate from this link Ionic 3 WP-REST API Post request 401 (unauthorized) error & WooCommerce REST API "woocommerce_rest_cannot_view "

2 Comments

queryStringAuth: true was the solution for me
Sorry I have no idea about wordpress. I am unable to find woocommerce init. Any clue?
0

401 is unauthorized error

if key and secret are correct, it could be todo with SSL

other people report similar problems

https://github.com/woocommerce/woocommerce/issues/19649

Comments

0

Problem solved by adding this line below to the end of .htaccess file

All you need to add this line to .htaccess , this work with me

SetEnv HTTPS on

And make sure use OAuth 1.0 for Authorization

enter image description here

Comments

0

add false in end of creating RestAPI like this...

RestAPI rest = new RestAPI(URL, ConsumerKey, ConsumerSecret, false);

it should by "authorizedHeader"

answer from https://github.com/XiaoFaye/WooCommerce.NET/issues/211

Comments

0

None of the suggestions helped me, so I deleted my previous API credentials and created new ones. This made the change for me.

I don't want to say "just delete your credentials" as you have to make sure to not break any necessary connections, please note that! I'm just sharing my experience on this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.