Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post delete put function success but it did not add delete or change product #95

Open
markhsiaowork opened this issue May 10, 2021 · 2 comments

Comments

@markhsiaowork
Copy link

markhsiaowork commented May 10, 2021

post delete put function success but it did not add delete or change product

So I am trying to add a product to my woo-commerce shop using the woocommerce-rest-api. I can successfully retrieve a list of the products using the WooCommerce.get("products") method, but when I used the post method to add a new product. It successfully give me a response (showing the list of products) but it did not add the new product.

//CONFIG
const WooCommerceRestApi = require("@woocommerce/woocommerce-rest-api").default;
const WooCommerce = new WooCommerceRestApi({
  url: "https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com",
  consumerKey: "ck_xxxxxxxxxxxxxxxxxxxxxxxxxxx",
  consumerSecret: "cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  version: "wc/v3",
  queryStringAuth: true,
});
//NEW PRODUCT

const data = {
  name: "Premium Quality", // See more in https://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties
  type: "simple",
  regular_price: "21.99",
};
//POST
WooCommerce.post("products", data)
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.log(error.response.data);
  });

@markhsiaowork markhsiaowork changed the title post function success but it did not add product post delete put function success but it did not add product May 12, 2021
@markhsiaowork markhsiaowork changed the title post delete put function success but it did not add product post delete put function success but it did not add delete or alter product May 12, 2021
@markhsiaowork markhsiaowork changed the title post delete put function success but it did not add delete or alter product post delete put function success but it did not add delete or change product May 12, 2021
@anoblet
Copy link

anoblet commented Aug 9, 2021

Did you ever find a solution to this?

@markhsiaowork
Copy link
Author

Yeah, so the problem is inside my config where
url: "https://example.com. I just put a https://(www).example.com and it worked.

Because when I submit a post request I point it to the URL example.com which will get redirect to the actual address www.example.com and every time it redirects it will change to Get request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants