Metafield Bugs on Rest Api Version 2021-07

Jayvin
Shopify Partner
254 39 67

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.

k_andersen
Tourist
3 0 2

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. 

 

0 Likes
Jayvin
Shopify Partner
254 39 67

@k_andersen 

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.

k_andersen
Tourist
3 0 2

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

k_andersen
Tourist
3 0 2

@Jayvin 

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-07type 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.

Jayvin
Shopify Partner
254 39 67

Hi @k_andersen 

Thanks for the info. I will wait for the 2021-10 version then do the updates.

0 Likes