Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi,
We are switching over to 2021-07 api version and noticed couple of bugs with metafields endpoint when using Rest API services.
Customers endpoint:
PUT /admin/api/2021-07/customers/5292182730.json
{
"customer": {
"id": 5292182730,
"metafields": [
{
"key": "test4",
"namespace": "devops",
"type": "number_integer",
"value": 51
}
]
}
}
Error:
{
errors: { 'metafields.value_type': [ 'is not included in the list' ] }
}
Products endpoint:
PUT /admin/api/2021-07/products/5040616004.json
{
"product": {
"metafields": [{
"namespace": "c_f",
"key": "artist",
"value": "CHEMICAL BROTHERS",
"type": "single_line_text_field"
}, {
"namespace": "c_f",
"key": "label",
"value": "Virgin",
"type": "single_line_text_field"
}]
}
}
Same errors on both above endpoint.
Im experiencing the same issue.
Looks like the metafields node on the PUT request does not expect the new format of metafields, and is expecting a value_type to be supplied instead of a type.
{
"errors": {
"value_type": [
"is not included in the list"
]
}
}
This method is really important as its (as far as i know) the only way to update multiple metafields in a single request. Alternative would be to do a request for each metafield.
This method is really important as its (as far as i know) the only way to update multiple metafields in a single request. Alternative would be to do a request for each metafield.
Agree, the alternative works.
But there are many apps out there that uses the update multiple metafields in a single request and so this MUST be fixed.
I thought i was the only one to use the put method to update multiple metafields at once. Good to hear i'm not. And i totally agree that this is a must fix, based on your explanation
Take a look at this page - looks like this will be fixed in 2021-10 API release
https://shopify.dev/apps/metafields/manage.md#known-issues-for-metafield-types
When using the REST Admin API version 2021-07, type is available for metafields only when querying the Metafield resource directly (/admin/api/2021-07/products/PRODUCT_ID/metafields.json). When querying a resource that can contain metafields, such as the Product resource (/admin/api/2021-07/products.json), the API still uses value_type for metafields. This issue will be fixed in API version 2021-10.
Hi @k_andersen
Thanks for the info. I will wait for the 2021-10 version then do the updates. 🙂
Hi,
Can you try with api version 2021-10?
2021-04 and 2021-07 versions had some issues when creating multiple metafields on customer or product entity.