App reviews, troubleshooting, and recommendations
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:
Metafield Creation:
API Request:
Error Response:
Here's my request:
url -X POST "<store>/admin/api/2023-10/products/<id>/metafields.json" -H "X-Shopify-Access-Token: <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\"]."]
}
}
Hi,
https://shopify.dev/docs/api/admin-graphql/2023-10/objects/Metafield
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. | [] | yes | no |
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025