All things Shopify and commerce
Trying to test the Put Api in postman , this put api is used update a product, here's the curl of it as per the document,
curl -d '{"product":{"id":632910392,"metafields":[{"key":"new","value":"newvalue","type":"single_line_text_field","namespace":"global"}]}}' \
-X PUT "https://your-development-store.myshopify.com/admin/api/2023-10/products/632910392.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"
Now instead of type : "single_line_text_field", i want to use type : " list.single_line_text_field" and here's how the body of put api is , but i get the error stating
But as per the document for the type :list.single_line_text_field, the value should be framed like below, and i have done the same, can you help here!
[
"VIP shipping method",
"Standard shipping method"
]
The URL is
https://e83a4c-2.myshopify.com/admin/api/2021-07/products/8436655128805.json
BODY is :
it seems that you are encountering a common issue with the Shopify API when using a list.single_line_text_field metafield type. In your case, the error message "expected Array to be a string" indicates a mismatch between the expected data format for the metafield type and the format of the value you are providing.
In Shopify, different metafield types have specific data format requirements. For the single_line_text_field type, the value is expected to be a plain string with no line breaks, and this type can be used in a list. However, when you switch to list.single_line_text_field, it seems that the API might still be expecting a string representation of the list, not an actual JSON array.
A possible solution could involve formatting your list as a string that represents the array. This means you might need to convert your array into a string format that looks like an array but is actually a string.
Here's a general idea:
{
"product": {
"id": 8436655128805,
"metafields": [
{
"key": "lily-1",
"type": "list.single_line_text_field",
"value": "[\"VIP shipping method\", \"Standard shipping method\"]",
"namespace": "lily"
}
]
}
}
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025