Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I'm using the Admin REST API in a Rails app, and have a strange problem getting metafields for products.
In one shop I can get all the metafields for a resource, but on another shop I only get back metafields that I have manually created in the shop. No other metafields are returned from that shop for a resource.
For example, if the resource is a product and it has my manually created metafield, that metafield is returned, if not then I get back an empty array, despite that product having several different metafields.
Both shops have the same apps installed, and the Private App scopes are identical for both shops.
What am I missing here? Is there some other permission setting to expose all the metafields to the Admin API?
Without tangible examples there's not a lot we could talk through here. Are you sure they have not been privately scoped?
https://shopify.dev/docs/admin-api/graphql/reference/metafields/privatemetafield
What call are you making? Or at leat the response id that comes back in the header.
Hey Jason!
I'm fairly certain the metafields that aren't being returned by the API are not privately scoped as the exact same metafields exist for products on another store, and were created by the same apps (Stamped Reviews & Accentuate Custom Fields), so they should be scoped the same on both stores.
I'm just making a GET call like this:
product = ShopifyAPI::Product.find(id)
product_metafields = product.metafields
Which is either returning the one metafield I manually created to test, or an empty array [].
Can you make the same call in something like Postman to rule out your tech stack? It's unlikely, but worth covering off the basics.
With a Response ID it's something that could be dug into more.
Hey Jason,
I ran it in Postman and it came back fine. So with that confirmed I went back over my code, and found my silly mistake. Problem solved.