Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I’m trying to update a product metafield using the Shopify REST Admin API, but I’m encountering an error. Here’s the current setup:
Metafield Details:
{
"metafields": [
{
"id": 44534555355,
"namespace": "custom",
"key": "entries",
"value": 5,
"description": null,
"owner_id": 24244536956,
"created_at": "2024-08-23T05:02:10-06:00",
"updated_at": "2024-09-16T06:44:44-06:00",
"owner_resource": "product",
"type": "number_integer",
}
]
}
update payload:
{
"metafield": {
"product_id": 24244536956,
"id": 44534555355,
"key": "entries",
"namespace": "custom",
"value": 10,
"type": "number_integer"
}
}
Error Message:
{
"errors": {
"metafield": "Required parameter missing or invalid"
}
}
I’ve checked the API documentation and my payload, but it seems like I’m missing something. Can someone help me identify what’s causing this error and how to properly format the update payload?
Your update code should also be "owner_id", not "product_id". Metafields know their relationship to other data by the "owner_resource" type specified when you create the field, not any other data.
Additionally, if you're only updating the value and not changing anything else about the metafield, you only need to send over "id", "value", "type".