Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hey There,
Wondering if anyone has any guidance... I am sending the below payload to the following URL, but seem to be getting a bad request error. namespace and key are correct, as it the type.
https://{{store_name}}.myshopify.com/admin/api/{{api_version}}/variants/{{variant_id}}/metafields.json
{
"metafield": {
"namespace": "theme",
"key": "highlight",
"value": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
"type": "list.single_line_text_field"
}
}
Hey @Chris_Sydney
I think the payload has to include the variant ID, e.g.:
{"variant":
{
"id":808950810,
"metafields": [
{"key":"new","value":"newvalue", etc.. }
]
}
}
More here: https://shopify.dev/docs/api/admin-rest/2023-07/resources/product-variant#put-variants-variant-id
Let me know if you get stuck!
Scott | Developer Advocate @ Shopify
thanks, yeah I kind of landing on this, I need to write the payload before it sent via the admin API.
With the given curl command, you can invoke the admin API.