The following PUT request to the Admin REST API results in a 200 but does not actually update the article data
URL:
https://{{shopify_store_name}}.myshopify.com/admin/api/2023-10/blogs/{{shopify_blog_id}}/articles/{{article_id}}.json
Body:
{
"article":{
"id": {{article_id}},
"title": "Updated title",
"body_html": "Updated content",
"metafields":[
{
"key":"author_name",
"value":"Updated Author Name",
"type":"single_line_text_field",
"namespace":"global"
}
]
}
}
Hey @Shopify_77 ,
It turns out that if you need to update an existing metafield value, at least on a blog article, then you need to include the id of the metafield (not just the key). Otherwise the entire request fails silently, returns a 200 and the response indicates the request worked even though it did not. It seems like this case should instead return a bad request and a validation message.
It would also be helpful to add an example of updating a metafield value here:
https://shopify.dev/docs/api/admin-rest/2023-10/resources/article#Addametafieldtoanexistingarticle
This Body works:
{
"article":{
"id": {{article_id}},
"title": "Updated title",
"body_html": "Updated content",
"metafields":[
{
"key":"author_name",
"value":"Updated Author Name",
"id": {{metafield_id}},
"type":"single_line_text_field",
"namespace":"global"
}
]
}
}
Thanks