I
I
Ib0bI2019-05-07 16:04:42
WordPress
Ib0bI, 2019-05-07 16:04:42

Solving 401 status in wordpress API?

Greetings.
I am trying to set up a WooCommerce API.
Through the admin panel, I received 2 keys consumer_key and consumer_secret with the ability to read and write.
It gives 404 on invalid requests, which is great.
But when I try to send requests to valid routes, I get a 401 status (woocommerce_rest_cannot_edit-You do not have permission to edit this resource)
Examples of my requests:
1.MYSITE/wp-json/wc/v2/products/36?consumer_key=key&consumer_secret =key (POST request)
2.MYSITE/wp-json/wc/v2/products/36?_method=DELETE (via POSTMAN)
3.MYSITE/wp-json/wc/v2/products/36 (via POSTMAN method DELETE with basic authentication)
4.curl -X DELETE --user login:password -i MYSITE/wp-json/wc/v2/products/36 (via curl)
5.curl -X DELETE --user login:password(base 64) -i MOISITE/wp-json/wc/v2/products/36 (via curl)
Absolutely everyone gives status 401, although the keys have admin rights.
What could be the problem?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Koryakin, 2019-05-08
@zettend

Authentication should be passed with every request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question