I am working on integrating Shopify’s Admin API for our store(store URL: rrtrxj-h1.myshopify.com).
I am attempting to update a custom metafield (mihai_variable_gallery) of type list.file_reference for a specific product variant, but I am encountering errors during the process.
Metafield Details
• Metafield Key: mihai_variable_gallery
• Metafield URL in Admin: /store/rrtrxj-h1/settings/custom_data/productvariant/metafields/187111211345
• Metafield Type: list.file_reference
Product Variant Details
• Product Variant URL in Admin: /store/rrtrxj-h1/products/9864017871185/variants/50241067090257
• Product ID: 9864017871185
• Variant ID: 50241067090257
Issue Description
I am trying to update the mihai_variable_gallery metafield with the following values:
[“gid://shopify/ProductImage/66131787907409”, “gid://shopify/ProductImage/66131788005713”]
Errors Encountered
- When passing the array as a JSON-encoded string:
• Request:
{
“metafield”: {
“namespace”: “custom”,
“key”: “mihai_variable_gallery”,
“value”: “["gid://shopify/ProductImage/66131787907409"]”,
“type”: “list.file_reference”
}
}
• Response Error:
metafields.value: must be a file reference string.
- When passing a single file reference string:
• Request:
{
“metafield”: {
“namespace”: “custom”,
“key”: “mihai_variable_gallery”,
“value”: “gid://shopify/ProductImage/66131787907409”,
“type”: “list.file_reference”
}
}
• Response Error:
metafields.value: must be an array.
- When passing the value as an array directly:
• Request:
{
“metafield”: {
“namespace”: “custom”,
“key”: “mihai_variable_gallery”,
“value”: [“gid://shopify/ProductImage/66131787907409”],
“type”: “list.file_reference”
}
}
• Response Error:
value: expected Array to be a String.
Debugging Steps Taken
-
Ensured the file references (e.g., gid://shopify/ProductImage/66131787907409) are valid and exist in Shopify.
-
Used Go’s json.Marshal to encode the array into a JSON string for proper formatting.
-
Confirmed that the metafield type is correctly set to list.file_reference.
-
Tested payloads using both Shopify’s Admin API and Postman, but the errors persist.
Request for Assistance
Could you please help me understand the following:
- What is the exact format required for the value field when updating a metafield of type list.file_reference? It seems I go in circles. When I use an array I get an error that it must be string and the other way around.