Re: Product List Metafields JSON format

How do you format JSON for product list metafields?

mitchelldirt
Shopify Partner
9 1 4

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 🙂

Web Developer
Replies 5 (5)

MetafieldsGuru
Shopify Partner
160 32 102

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"
}
Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension
lthomas1
Shopify Partner
30 0 5

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

 

MichaelSD
Shopify Partner
4 0 0

Hi @lthomas1,

 

Were you able to get this resolved ?

... or did you find a workAround ?

 

Many Thanks, Michael

lthomas1
Shopify Partner
30 0 5

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

MichaelSD
Shopify Partner
4 0 0

Hi @mitchelldirt 


Wondered if you had been able to resolve this.

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

 

Thanks, Michael