fahadmahmood8/stock-locations-for-woocommerce

Rest-API-Integration

Closed this issue · 1 comments

Hello,

First of I want to thank you for this project. I am currently developing a frontend interface, in which I want to enable the creation of products. My problem is that I am not able to create or update the products locations via a REST-API.

What I have tried:

  • When creating a product via the /wp-json/wc/v3/products/ endpoint (POST) passing locations as a URL-parameter with the following array as plain-text:
    [
    { "id": 35, "name": "Baustelle Frankfurt", "slug": "baustelle-frankfurt", "quantity": "0" },
    { "id": 34, "name": "Baustelle München", "slug": "baustelle-muenchen", "quantity": "0" },
    { "id": 33, "name": "Hauptlager", "slug": "hauptlager", "quantity": "10" }
    ]

  • base64 encoding the upper text and then passing it as the url-argument.

  • First creating the product and then updating it via the /wp-json/wc/v3/products/{{productId}} endpoint (PUT) and passing locations as a URL-parameter.

Do you know what I am doing wrong - or what I could try instead?

Have a great day,
Leon