A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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!
Solved! Go to the solution
This is an accepted solution.
Hi @renkye 👋
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!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hi @renkye 👋
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!
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
That works, thank you! Strangely it doesn't work with ThunderClient which is a VSCode extension.