當我更新多個變種產品,我得到一個錯誤 響應:Shopify API重複PUT有不同的結果(選項不是唯一的)
{"errors":{"base":["Options are not unique"]}}
或有時:
{"errors":{"variants":["is invalid"], "base":["Options are not unique"]}}
我我正在使用如下數據向 /admin/products/122821632.json發出PUT請求:
{"product":{"id":"122821632",
"body_html":"test",
"vendor":"Acme",
"title":"Monkey T-Shirt",
"variants":[{"option1":"LARGE",
"sku":"test-sku-2",
"product_id":"122821632",
"id":"282988194",
"price":"21.99",
"grams":"200"},
{"option1":"TINY",
"sku":"test-sku-1",
"product_id":"122821632",
"id":"282990692",
"price":"21.99",
"grams":"200"}],
"options":[{"position":1,
"name":"Size",
"product_id":"122821632"}]}}
但我注意到,如果我把單個變體,然後把 多變量數據JSON,它的作品。這確實意味着刪除一個 變體並重新創建它,我認爲這是不可接受的 插件的行爲,特別是因爲我沒有關於變體存儲的所有數據 ,因此無法展開進入 生產。
要做到這一點,我讓這些PUT請求:
{"product":{"id":"122821632",
"body_html":"test",
"vendor":"Acme",
"title":"Monkey T-Shirt",
"variants":[{"option1":"LARGE",
"sku":"test-sku-2",
"product_id":"122821632",
"id":"282988194",
"price":"21.99",
"grams":"200"}],
"options":[{"position":1,
"name":"Size",
"product_id":"122821632"}]}}
它返回一個200跟:
{"product":{"id":"122821632",
"body_html":"test",
"vendor":"Acme",
"title":"Monkey T-Shirt",
"variants":[{"option1":"LARGE",
"sku":"test-sku-2",
"product_id":"122821632",
"id":"282988194",
"price":"21.99",
"grams":"200"},
{"option1":"TINY",
"sku":"test-sku-1",
"product_id":"122821632",
"id":"282990692",
"price":"21.99",
"grams":"200"}],
"options":[{"position":1,
"name":"Size",
"product_id":"122821632"}]}}
它返回一個200跟:
{"product":{"id":"122821632",
"body_html":"test",
"vendor":"Acme",
"title":"Monkey T-Shirt",
"variants":[{"option1":"LARGE",
"sku":"test-sku-2",
"product_id":"122821632",
"id":"282988194",
"price":"21.99",
"grams":"200"},
{"option1":"TINY",
"sku":"test-sku-1",
"product_id":"122821632",
"id":"282990692",
"price":"21.99",
"grams":"200"}],
"options":[{"position":1,
"name":"Size",
"product_id":"122821632"}]}}
這給了我錯誤。另外,變種的ID我刪除和 重新改變了(我可以用GET請求告訴):
{"product":{"body_html":"test",
"handle":"69",
"images":[],
"template_suffix":null,
"product_type":"Shirts",
"updated_at":"2013-03-07T11:36:51-05:00",
"variants":[{"position":1,
"option1":"LARGE",
"option2":null,
"option3":null,
"updated_at":"2013-03-07T07:30:15-05:00",
"inventory_quantity":1,
"title":"LARGE",
"product_id":122821632,
"created_at":"2013-03-06T11:03:36-05:00",
"compare_at_price":"24.99",
"fulfillment_service":"manual",
"inventory_management":"",
"sku":"test-sku-2",
"taxable":true,
"requires_shipping":true,
"price":"21.99",
"inventory_policy":"deny",
"id":282988194,
"grams":200},
{"position":2,
"option1":"TINY",
"option2":null,
"option3":null,
"updated_at":"2013-03-07T11:36:51-05:00",
"inventory_quantity":1,
"title":"TINY",
"product_id":122821632,
"created_at":"2013-03-07T11:36:51-05:00",
"compare_at_price":null,
"fulfillment_service":"manual",
"inventory_management":null,
"sku":"test-sku-1",
"taxable":true,
"requires_shipping":true,
"price":"21.99",
"inventory_policy":"deny",
"id":283397624,
"grams":200}],
"title":"Monkey T-Shirt",
"created_at":"2013-02-22T05:35:02-05:00",
"options":[{"id":147204272,
"name":"Size",
"position":1,
"product_id":122821632}],
"vendor":"Acme",
"id":122821632,
"published_at":"2013-02-22T05:35:02-05:00",
"tags":"mens t-shirt example"}}
我的印象是,相同的數據 的第二PUT請求相同的URL應該不會導致變化。
我在做什麼錯?這是Shopify API中的錯誤嗎?