How do you format JSON for product list metafields?

Topic summary

Core Issue:
The original poster asked how to format JSON for Shopify’s product list metafield when integrating with NetSuite.

Correct Format:
Multiple respondents clarified that Shopify expects an array of product GIDs, not a key-value object:

[
  "gid://shopify/Product/12345",
  "gid://shopify/Product/67890"
]

Key Technical Details:

  • Must be a JSON array ([]), not an object ({})
  • Each entry is a string containing the product’s global ID (GID)
  • GID format: gid://shopify/Product/{product_id}
  • Metafield type should be list.product_reference

Implementation Challenge:
One user encountered a “406 Not Acceptable” error when using a PUT request to products/{id}/metafields.json. They resolved it by switching to the metafields endpoint directly: metafields/{metafield_id}.json.

Status:
The formatting question has been answered with working examples and code snippets. At least one user successfully implemented the solution using the alternative API endpoint.

Summarized with AI on October 24. AI used: claude-sonnet-4-5-20250929.

Does anyone know how you would format the JSON for the product list metafield. Is it something like:

{

“Product1”: “gid://12345”,

“Product2”: “gid://12345”,

“Product3”: “gid://12345”,

}

Trying to pass it through a connector with NetSuite and want to make sure it’s formatted the correct way :slightly_smiling_face:

1 Like

Hi @mitchelldirt ,

Here’s an example of a properly formatted JSON:

{
   "namespace":"related_products",
   "key":"product_list",
   "value":"[\"gid:\/\/shopify\/Product\/4558550859913\",\"gid:\/\/shopify\/Product\/4558550499465\",\"gid:\/\/shopify\/Product\/4593300471945\",\"gid:\/\/shopify\/Product\/4585581805705\",\"gid:\/\/shopify\/Product\/4558550597769\"]",
   "type":"list.product_reference"
}

Hello,

Can anyone help on this, I am trying to create a metafield for the same - list.product_reference.
Trying a PUT request to products/{id}/metafields.json

Below is the json

{
“metafield”: {
“namespace”: “custom”,
“key”: “rec_products”,
“value”: “["gid://shopify/Product/6883816472685","gid://shopify/Product/6883816538221"]”,
“value_type”: “json_string”,
“type”: “list.product_reference”
}
}

Getting an error - 406Not Acceptable

Thanks,
Lily

Hi @lthomas1 ,

Were you able to get this resolved ?

… or did you find a workAround ?

Many Thanks, Michael

Hi @mitchelldirt

Wondered if you had been able to resolve this.

Facing the same issue, and looking at options to resolve.

Thanks, Michael

Yes @MichaelSD
Instead of updating using products api, I used “metafields/{metafield_id}.json”
A PUT request to the above worked for me.
Payload similar to below -
{“metafield”: {“namespace”: “custom”, “key”: “rec_products”, “value”: “[“gid://shopify/Product/{product id}”]”, “type”: “list.product_reference”}}

Thanks,
Lily

When you’re working with Shopify metafields for product lists, the format isn’t a freeform JSON object like your example — Shopify expects an array of product GIDs (global IDs), not key-value pairs.

For a product list metafield, the correct JSON looks like this:

[
  "gid://shopify/Product/12345",
  "gid://shopify/Product/67890",
  "gid://shopify/Product/54321"
]

So your NetSuite connector should just pass the array of product GIDs as a stringified JSON array, not an object with product labels.

you can un this through any JSON validator or formatter tool like ValidateJSON

Hi @mitchelldirt

Great question :ok_hand:

Shopify product list metafields don’t use arbitrary key/value JSON like "Product1": "gid://...".
They expect an array of product references in JSON.

The format looks like this:

[
  "gid://shopify/Product/1234567890",
  "gid://shopify/Product/9876543210",
  "gid://shopify/Product/5432167890"
]

Key points:

  • It must be a JSON array ([ ]), not an object ({ }).
  • Each entry is a string containing the GID of a product.
  • GID format is always:
gid://shopify/Product/{product_id}
  • You can fetch the correct GIDs from the Admin API or GraphQL API (id field).

Example metafield definition in Shopify (type: Product List) would accept the above format.
If you’re pushing this through a connector to NetSuite, you should serialize it exactly like that array.