2017-02-08 12 views
1

既存の製品IDにバリアントを追加しようとしています。 以下は私が行ったJSONリクエストです。しかし、私はエラーが発生していますShopifyでバリアントを追加しようとするとエラーが発生する

{"errors":{"variant":"expected Array to be a Hash"}} 

JSONリクエスト。

{"variant": [{"product_id": 10065509898,"title": "XS\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_XS","position": 1,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "XS","option3": null,"taxable": true,"barcode": "80","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true},{"product_id": 10065509898,"title": "S\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_S","position": 2,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "S","option3": null,"taxable": true,"barcode": "80","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true},{"product_id": 10065509898,"title": "M\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_M","position": 3,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "M","option3": null,"taxable": true,"barcode": "80","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true},{"product_id": 10065509898,"title": "L\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_L","position": 4,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "L","option3": null,"taxable": true,"barcode": "80","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true},{"product_id": 10065509898,"title": "XL\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_XL","position": 5,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "XL","option3": null,"taxable": true,"barcode": "80","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true},{"product_id": 10065509898,"title": "XXL\/ BROWN","price": 49.05,"sku": "BA1015_BROWN_XXL","position": 6,"grams": 0,"inventory_policy": "deny","compare_at_price": null,"fulfillment_service": "manual","inventory_management": "shopify","option1": "BROWN","option2": "XXL","option3": null,"taxable": true,"barcode": "80","inventory_quantity": 0,"old_inventory_quantity": 0,"inventory_quantity_adjustment": 1,"weight": 1,"weight_unit": "lb","requires_shipping": true}]} 

私は間違っていますか?

+0

あなたはRESTfulな通話をしていますか? PUTまたはPOSTですか?既に製品に既存のバリアントがありますか? – HymnZ

答えて

1

これは、バリアントの配列を送信しているためです。あなたは別途add each variantにあります

POST /admin/products/{product_id}/variants.json

{ 
    "variant": { 
     "option1": "BROWN", 
     "price": "49.05", 
     "sku": "BA1015_BROWN_XS" 
    } 
} 

あなたがcreating a new productている場合にのみ、バリアントの配列を渡すことができます。

+0

製品に「PUT」を使用して複数のバリアントを追加することもできます。 – HymnZ

+0

@HymnZは既存のバリアントを置き換えるため注意してください。 –

+0

いいえ..配列にバリアントIDを指定すると、既存のバリアントを新しいバリアントで保持することができます。 – HymnZ

関連する問題