Re: Error retrieving list of metafields for all products

Error retrieving list of metafields for all products

Adverity_prod
Shopify Partner
8 0 0

Hi there,

 

As per your documentation here https://shopify.dev/docs/api/admin-rest/2023-01/resources/metafield#get-metafields?metafield[owner-i..., one should be able to get a list of metafields for an owner resource without needing to specify any IDs. 

 

However, I used the following curl in postman and while it does return a list of metafields, it always only returns it for the 'Shop' owner resource: 

curl --location --globoff --request GET 'https://simba-mattress.myshopify.com/admin/api/2023-04/metafields.json?metafield[owner_resource]=pro...' \
--header 'User-Agent: Adverity/2023.41.0.2' \
--header 'Accept-Encoding: gzip, deflate' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--header 'X-Shopify-Access-Token: REMOVED'

Response example:

{
"id": 10590251525,
"namespace": "kudobuzz",
"key": "review_count",
"value": 0,
"description": null,
"owner_id": 10594836,
"created_at": "2015-11-30T17:19:28+00:00",
"updated_at": "2015-11-30T17:19:28+00:00",
"owner_resource": "shop",
"type": "integer",
"admin_graphql_api_id": "gid://shopify/Metafield/10590251525"
},

What could I be doing wrong here?

A quick response would be really really appreciated 😊

Thank you!

Replies 12 (12)

Liam
Community Manager
3108 341 879

Hi Adverity_prod,

 

Adding [owner_resource]=product as a parameter to the query should filter the results to only give you products, so your query looks okay. Could you try the same curl GET request in terminal instead of Postman to see if there's something on Postmans side that is preventing the owner resource parameter from working?

 

 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Adverity_prod
Shopify Partner
8 0 0

Hi Liam,

 

I tried it in terminal and unfortunately, it still provides the same output. 

Adverity_prod
Shopify Partner
8 0 0

Hi Liam,

 

Just following up here as getting this data is a priority for our client. Thank you so much!

Liam
Community Manager
3108 341 879

Also just one thing to confirm - in your shared call you posted, the API endpoint url is "GET 'https://simba-mattress.myshopify.com/admin/api/2023-04/metafields.json?metafield[owner_resource]=pro...' \" is the url just cutting off here, as it's supposed to be in this format:

 

GET "https://your-development-store.myshopify.com/admin/api/2023-10/metafields.json?metafield%5Bowner_id%5D=382285388&metafield%5Bowner_resource%5D=product" \

 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Adverity_prod
Shopify Partner
8 0 0

Hi Liam,

 

Yes it's just cutting off here. 

Liam
Community Manager
3108 341 879

Hi again Adverity_prod,

 

Still looking into this, but could you try the equivalent call but using GraphQL instead? It is possible to filter by owner type with GraphQL too - even just testing with the GraphiQL app might be a quick way to see if the expected results are appearing.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Adverity_prod
Shopify Partner
8 0 0

Hi Liam,

 

I'm not familiar with the graphQL version so it would be helpful if you could provide a sample curl I can paste to Postman to save time - but regardless I'll check it out and get back to you.

 

Adverity_prod
Shopify Partner
8 0 0

Hi Liam,

 

Were you able to find any new information for the REST API? 

Liam
Community Manager
3108 341 879

Hi Adverity_prod,

 

I'm afraid it looks like GraphQL is the best option right now - did you get a chance to test it with the GraphiQL app?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Adverity_prod
Shopify Partner
8 0 0

Hi Liam,

 

Unfortunately, our integration only uses the REST version of Shopify right now. Were you able to get any insights on why this filter does not work? Any help would be greatly appreciated.

palakpatel
Shopify Partner
1 0 0

Hi Liam,

I am also facing the same problem.

With REST API always returning "shop" owner type data.

Tried with Admin GRAPHQL API and it returns only metafields with definition. meta fields without definition and global meta fields are missing.

palakpatel_0-1704107017687.pngpalakpatel_1-1704107062142.png

I want to get list of all metafields (Global, custom with and without definition).

mhennekam
Tourist
5 1 0

Hi Liam,

 

Like Adverity and like Palakpatel I would like to use the metafields.json endpoint of the REST API. I am experiencing the same problems already mentioned. Also this discussion seems to be no longer followed up on.

Should we conclude that the REST API is deprecated?

Or: the endpoint we would like to use is deprecated?

With best regards,

M. Hennekam

Entocare CV