Need to add more than 1 option for the product variant via api

Need to add more than 1 option for the product variant via api

seth_wright
Shopify Partner
2 0 1

im adding the product variants with the help of the documentation

as per the documents they're sending only option for the product variant, what my case is i have to add color and size for a product vairant

so im adding multiple options such as option1 for color, option2 size of the variants

i can able to add variant with 1 options if i add another option (i.e) option 2 means shopify throws an error

 

im adding product variants with more than 1 options which is contains size and colors here is my request

{ "variant": { "title": "test", "option1": "white", "option2": "s", "price": "40.00", "sku": "bank", "inventory_management": "shopify" } }

but im getting the error response from shopify like below

{#1278 +"errors": {#1277 +"base": array:1 [ 0 => "Option values provided for 1 unknown option(s)" ] } }

Replies 2 (2)

ShopifyDevSup
Shopify Staff
1453 238 509

Hey @seth_wright - the formatting on the POST request looks correct. Can you confirm if you're using this endpoint:

POST https://yourstore.myshopify.com/admin/api/2023-01/products/productID/variants.json

The only reason I can think of why that error would pop up is if you're using the products.json endpoint instead. If you can confirm you're using the right endpoint, could you share an X-Request-ID with us from the response header attached to the error message? This will help us pull the API call in our logs so that we can investigate further.

Hope this helps - please get back in touch if we can help out further. 

Al | Shopify Developer Support 

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

seth_wright
Shopify Partner
2 0 1

yes im adding the options in variant json endpoint option1 is working without error if we one or more variant the same errors im getting