Development discussions around Shopify APIs
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"
}
}
}
Solved! Go to the solution
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
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
I removed the additional params and it corrected the error.
Thanks for the tip.
Happy that you fixed. If you consider my answer useful please accept the solution, thank you.
User | RANK |
---|---|
10 | |
4 | |
3 | |
3 | |
3 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023