Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello
I have created several Metafields using the endpoint:
https://{store_name}.myshopify.com/admin/api/2023-01/products/8485254594898/metafields.json.
With Payload:
{"metafield":
{"key":"event_level",
"value":"[\"Beginner\"]",
"type":"list.single_line_text_field",
"namespace":"custom",
"owner_id":8389892768037,
"owner_resource":"product",
"id":0,
"admin_graphql_api_id":""}
}
If I go to Postman and get all the metafields from the product, they all show up:
https://{store_name}.myshopify.com/admin/api/2023-01/products/8485254594898/metafields.json
But on Shopify backoffice, I can't see them on Settings>Custom data, and I can't also see them on the product page.
Settings>Custom Data
Products
Any clues?
Solved! Go to the solution
This is an accepted solution.
It looks like you may need to create the metafield definition with the metafield
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
Hi RfcSilva,
On the admin panel from your first screenshot, if you click on the "Metafields without a definition" tab - are they 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
Hi Liam,
Yes, they do in fact appear on "Metafields without a definition" tab, I haven't noticed it.
But considering that I have put all the information necessary, should't it create that structure when creating the Metafield?
This is an accepted solution.
It looks like you may need to create the metafield definition with the metafield
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
Hello Liam,
Thank you, I was able to create correctly the Metafield with the mutation CreateMetafieldDefinition in GraphQl.
But I am curious, what do you mean by "You could also create the definition on the admin"? What endpoint is this? Or is it also GraphQl?
I used this solution according to your instructions an it works (future reference):
Endpoint:
https://{{store_name}}.myshopify.com/admin/api/2023-01/graphql.json
Query:
Variables:
Great to hear this is working as expected - for creating the metafield definition on the admin, I mean actually manually creating in on the store admin at Settings > Custom Data.
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
Hi Liam,
Can this be done using REST APIs instead of GraphQL?