I'm using Wordpress 4.7.1
with Woocommerce 2.6.13
plugin with enabled REST API. I was created user credentials from console plugin UI with read_write
permissions.
Now I'm trying GET products using OAuth1: service return 200 OK, credentials are right.
then I'm trying to DELETE some product: or trying to create new product: service return 401 Unauthorized.
Whats wrong?
UPD1: .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
This https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API#server-does-not-support-postdeleteput do the trick for me.
Some times, Server does not support POST/DELETE/PUT Ideally, your server should be configured to accept these types of API request, but if not you can use the _method property.
See https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/#_method-or-x-http-method-override-header
Doing a POST request, and passing _method=PUT as a query parameter works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With