Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Metafield Bugs on Rest Api Version 2021-07

Metafield Bugs on Rest Api Version 2021-07

Jayvin
Shopify Partner
284 42 89

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.

banned
Replies 6 (6)

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. 

 

Jayvin
Shopify Partner
284 42 89

@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.

banned
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
284 42 89

Hi @k_andersen 

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

banned

Jayvin
Shopify Partner
284 42 89

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.

banned