How to add a preset metafield to a product via API in Shopify?

I have encountered a problem while trying to add a pre-set metafield to a product via API in my store.
Below are the details of the issue:

  1. Metafield Creation:

    • I created a Product Metafield in my Shopify store.
    • Metafield Type: Single Line Text Field
    • Setting Enabled: Limit to Preset Choices
  2. API Request:

    • I attempted to add this metafield to a product using the following API request:

      jsonCopy code
      { “metafield”: { “namespace”: “custom”, “key”: “era”, “type”: “list.single_line_text_field”, “value”: [ “40s” ] } }

  3. Error Response:

    • I received the following error response:

      jsonCopy code
      { “errors”: { “value”: [ “can’t be blank.” ] } }

Here’s my request:

url -X POST “/admin/api/2023-10/products//metafields.json” -H “X-Shopify-Access-Token: ” -H “Content-Type: application/json” -d ‘{“metafield”: {“namespace”: “custom”,“key”: “Era”,“type”: “list.single_line_text_field”,“value”:[“40s”]}}’

I tried posting different type:
{
“errors”: {
“type”: [“‘single_line_text_field’ must be consistent with the definition’s type: ‘list.single_line_text_field’.”],
“value”: [" does not exist in provided choices: ["40s", "50s", "60s", "70s", "80s", "90s", "2000s"]."]
}
}

I have done get request for product which I manually in Shopify UI added metafields

“namespace”: “custom”,
“key”: “era”,
“id”: 42597399298391,
“value”: “["90s","70s","80s"]”,
“description”: null,
“created_at”: “2023-10-16T17:29:34+02:00”,
“updated_at”: “2023-10-16T17:29:34+02:00”,
“owner_resource”: “product”,
“type”: “list.single_line_text_field”,

Hi,

https://shopify.dev/docs/api/admin-graphql/2023-10/objects/Metafield

value
String!

The data stored in the metafield. Always stored as a string, regardless of the metafield’s type.

I think your value is an array, so you need to remove the in your value ?

Thank you for reply.
I tried this before and it does not work. Response:

{
“errors”: {
“value”: [“must be an array.”]
}
}

Also: see Shopify instructions for lists.

list.single_line_text_field A list of single-line text fields.

<br>[ <br>"VIP shipping method", <br>"Standard shipping method"<br>

]
yes no