New Shopify Certification now available: Liquid Storefronts for Theme Developers

How grab empty metafields in an API call

Solved
fajtorello
Tourist
3 1 0

Hi!

 

I have a store with functionalities heavily reliant on products custom metafields. For a non-technical person, creating a product like that would be super difficult to fill out properly, so I want to create a base in airtable from where all correct information would be filled and then passed to shopify with an API call. 

 

The problem is when metafields values are empty I cannot get their IDs. Using a method like 'Retrieve a list of metafields by using query parameters' returns an empty array. Similarly, i cannot get the metfields ids when I try to get them one by one. I saw on this forum that is a problem for other people as well, but found no answer... 
Hacky way might be creating a default value for every metafield, then i could retrieve the IDs and override the values, but I do not know if that's possible.


Has someone overcome this?

Accepted Solution (1)
fajtorello
Tourist
3 1 0

This is an accepted solution.

For anyone looking, the proper way to go about this is to use the Create Metafield method.  

View solution in original post

Replies 3 (3)
Jason
Shopify Expert
11159 222 2274

An empty metafield wouldn't exist as it needs _some_ value to create one.

 

If you've pulled all metafields on a product you'd know what ones exist though, and the values each contains.

 

 

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
fajtorello
Tourist
3 1 0

Hi, thanks for responding. I've understood I have used inaccurate names to describe my problem. What I meant is I have metafield definitions in place and I want to populate those definitions but don't know how to grab the definitions to put my data.

fajtorello
Tourist
3 1 0

This is an accepted solution.

For anyone looking, the proper way to go about this is to use the Create Metafield method.