1
I’m trying to send a POST
for Woocommerce/wordpress using the API Woocommerce-api, but I only get the error 401
what it says:
Fetch API cannot load http://wc-project.dev/wp-json/wc/v1/orders... Response for preflight has invalid HTTP status code 401
Typeerror: Failed to fetch at Typeerror (Native)
I already tried to add the permission via htaccess
with:
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin: "http://localhost:3000"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
Header add Access-Control-Allow-Headers: "Content-Type"
Header add Access-Control-Allow-Credentials: "true"
</IfModule>
I also tried right in the header.php
of my theme:
header("Access-Control-Allow-Origin: *");
And also in the archive functions.php
:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: *");
The POST
being performed from an application REACT
through the local server that is made available through the react-scripts start
By clicking on link
provided by error I receive the following JSON
:
{"code":"woocommerce_rest_authentication_error","message":"Assinatura inv\u00e1lida - a assinatura fornecida n\u00e3o corresponde.","data":{"status":401}}
The keys of API
already have permission and reading and writing.
Enter the code you are using for the request. The answer says the signature is invalid, so if the keys are correct, it must be something in the way they are being sent.
– Ricardo Moraleida
The method I’m sending is using the
.post()
of the package I informed.– RFL