Reputation: 1401
I can post a number of metafields for an existing product if I do it one at a time:
/admin/products/#{id}/metafields.json
{ "metafield":
{
"namespace":"c_f",
"key":"label",
"value":"Am:pm",
"value_type":"string"
}
}
When I try to add multiple fields in the same post, I am getting an error:
{ "metafields":[
{
"namespace":"c_f",
"key":"artist",
"value":"CHEMICAL BROTHERS",
"value_type":"string"
},
{
"namespace":"c_f",
"key":"label",
"value":"Virgin",
"value_type":"string"
}
]
}
The error is:
"metafield": "Required parameter missing or invalid"
API has examples of posting one metafield only. Is there any way I can combine the metafields (need about 8) into a single POST request?
Upvotes: 0
Views: 5499
Reputation: 4106
Try making a PUT
request like this one with the product:
PUT /admin/products/5040616004.json HTTP/1.1
Host: yourshop.myshopify.com
X-Shopify-Access-Token: 085abas8bd90325c3f81s8e9c88befc0
Content-Type: application/json
{
"product": {
"metafields": [{
"namespace": "c_f",
"key": "artist",
"value": "CHEMICAL BROTHERS",
"value_type": "string"
}, {
"namespace": "c_f",
"key": "label",
"value": "Virgin",
"value_type": "string"
}]
}
}
Upvotes: 8