Hi @scheidgabriel,
Testing creating a product using the REST API I was able to create the product successfully on my test installation of WooCommerce. The REST API endpoint which I used during that testing was this one below.
https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product
With regards to testing API calls we’d recommend using to see any errors, we have some information on testing API calls using an App called Postman and I’ve referenced that for you below too.
https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API
Hello @stuartduff
First of all, thanks you for your answer!
And I misspelled on my question. I’m not able to make POST requests.
That is the same endpoint I’m using.
I use Postman for testing. But not even in Postman I can use that endpoint.
I set everything up, the endpoint URL, then the following:
– “Params” tab: I add two keys: consumer_key and consumer_secret, and their respective values.
– “Authorization” tab: I select “Basic Auth”, and the username is the consumer key, and the password is the consumer secret.
– “Body” tab: I select “raw”, define it as JSON, then I write the JSON in the text area
– I define the method as POST
Then I hit “Send”. What the API returns is the same thing as if I used this endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products
I get no error messages. I get nothing but the list of all products, when I should receive back the product I tried to create.
I tried creating the product using Postman (like I described here) and I tried creating the product using the Visual Studio C# console application I developed to consume the API. After trying these 2 methods, I always log in the admin panel of the WooCommerce site I’m developing this for, and check the products. The one I tried to create is never there.
My C# console app GET and PUT requests work just fine. But my POST does not. I don’t know what I’m doing wrong.
Hi @scheidgabriel ,
I facing same issue with you. When I create product, it will return list of product with 200 status code. Should be 201. Have you got any solution for this? Since the discussion already stop assuming you find any solution or hint to prevent this happening.
Thanks.
@scheidgabriel @stuartduff @mrkhairi96 Have you guys figured it out? Facing the same issue.
Figured it out for me.
The problem:
– POST request to create a product returns 200 status code and a list of products instead of a new product.
The solution:
– according to this link it should be a server problem. So, adding &_method=POST to the path solves a problem
https://github.com/woocommerce/woocommerce/wiki/Getting-started-with-the-REST-API#server-does-not-support-postdeleteput
E.g.
https://example.org/wp-json/wc/v2/products?consumer_key=key&consumer_secret=secret&_method=POST