API: You need to add option values for Size

Solved
gvbrown
Shopify Partner
19 1 5

Hi all - 

I'm getting this error when attempting to add a variant through the API.  Options are posted in the json, however an error is returned indicating that values need to be submitted.  

 

JSON posted below: 

 

{
"variant": {
"title": "Bride-Black-S",
"product_id": 123456,
"options": [
{
"position": "1",
"values": [
"Black",
"City Green",
"Mandarin Orange"
],
"name": "Color"
},
{
"position": "2",
"values": [
"S",
"M",
"L",
"XL",
"2XL",
"3XL"
],
"name": "Size"
}
],
"variant": {
"position": "1",
"price": 20,
"barcode": "POD-123456-108-20-2",
"title": "Bride-Black-S",
"inventory_policy": "continue",
"sku": "POD-158758508-108-20-2",
"handle": "Bride - 158758508",
"option1": "Black",
"option2": "S"
}
}
}

Accepted Solution (1)
drakedev
Shopify Partner
680 145 212

This is an accepted solution.

When creating a new variant shouldn't be this code enough?

{
    "variant": {
        "position": "1",
        "price": 20,
        "barcode": "POD-123456-108-20-2",
        "title": "Bride-Black-S",
        "inventory_policy": "continue",
        "sku": "POD-158758508-108-20-2",
        "handle": "Bride - 158758508",
        "option1": "Black",
        "option2": "S"
    }
}

Doesn't' work?

Also be careful because I believe that handle only accepts the following characters:

0-9

a-z

A-Z (converted to lowercase)

_

and spaces are converted to hyphen

 

If my answer was helpful click Like to say thanks
If the problem is solved remember to click Accept Solution
Shopify/Shopify Plus custom development: You can hire me for simple and/or complex tasks.

View solution in original post

Replies 3 (3)
drakedev
Shopify Partner
680 145 212

This is an accepted solution.

When creating a new variant shouldn't be this code enough?

{
    "variant": {
        "position": "1",
        "price": 20,
        "barcode": "POD-123456-108-20-2",
        "title": "Bride-Black-S",
        "inventory_policy": "continue",
        "sku": "POD-158758508-108-20-2",
        "handle": "Bride - 158758508",
        "option1": "Black",
        "option2": "S"
    }
}

Doesn't' work?

Also be careful because I believe that handle only accepts the following characters:

0-9

a-z

A-Z (converted to lowercase)

_

and spaces are converted to hyphen

 

If my answer was helpful click Like to say thanks
If the problem is solved remember to click Accept Solution
Shopify/Shopify Plus custom development: You can hire me for simple and/or complex tasks.
gvbrown
Shopify Partner
19 1 5

I removed the additional params and it corrected the error.  

 

Thanks for the tip. 

 

 

drakedev
Shopify Partner
680 145 212

Happy that you fixed. If you consider my answer useful please accept the solution, thank you.

If my answer was helpful click Like to say thanks
If the problem is solved remember to click Accept Solution
Shopify/Shopify Plus custom development: You can hire me for simple and/or complex tasks.