Trying to add a product variant returns 400 Error

Hello,

I’m trying to add a product variant with the API but I get a 400 error as return. Getting product variants works fine, so there doesn’t seem to be an authentication issue.

Here is my POST request:

store-url/admin/api/2023-01/products/8076991627548/variants.json?product_id=8076991627548&option1=“Blau”&price=“50.00”

Thanks for your help!

Hi [email removed]renkye :waving_hand:

It’s a little unclear how you’re making request. I’d recommend trying the below curl request instead:

curl -L -X POST 'https://STORE_URL.myshopify.com/admin/api/2023-01/products/8076991627548/variants.json' \
-H 'X-Shopify-Access-Token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
--data-raw '{
    "variant": {
        "option1": "Blau",
        "price": "50.0"
    }
}'

Hope that helps!

That works, thank you! Strangely it doesn’t work with ThunderClient which is a VSCode extension.