Solved

Not able to get list of metafields for Product through Rest API

amruta
Shopify Partner
1 0 0

Cannot get all the meta fields for Product resource. Tried below api's but none of them gives all the metafields

 

1)api/2022-01/products/6781390094435/metafields.json? - This returns only metafields that has value

2)api/2022-01/metafields.json?metafield[owner_resource]=product&metafield[owner_id]=6781390094435 -This also returns metafields which has value

 

Need to get metafields for product even if it does not have value (if possible not for particular product)in order to identity the type of control.

 

Thanks

 

Accepted Solution (1)
MetafieldsGuru
Shopify Partner
158 32 99

This is an accepted solution.

If you have set up metafield definitions for your store, you can get the data like metafield type from there.

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension

View solution in original post

Replies 3 (3)

MetafieldsGuru
Shopify Partner
158 32 99

Hi @amruta ,

 

Sadly, it's not possible to retrieve metafields that don't have value. A metafield is not a standard product field; it is a child resource added to a product object. Metafields simply don't exist until you create them (either manually or via the API), and a value must be added for a metafield to exist.

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension
smarenich
Shopify Partner
1 0 0

The problem here is that we need to know the type of the metafield before we send the value, but if we can't select it, we can't get the type.

Is there a way to determine the type of the metafield before we create a product with the field?

MetafieldsGuru
Shopify Partner
158 32 99

This is an accepted solution.

If you have set up metafield definitions for your store, you can get the data like metafield type from there.

Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension