Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello, I've managed to use the PUT and POST requests to add metafields to my customers. However, after the initial insertion of the data, i cannot update the metafields because i need to pass the ID of the metafield to update. However, I can't get the actually metafields using the shopify API.
I'm using https://stuff:stuff@domain/admin/customers/100.json to get the json data of a custom, but the metafields are missing. However, in liquid if i use {{ customer.metafields.namespace }} the data is present.
Any ideas?
You never get metafield resources when you request a parent resource like a customer, product or variant. You have to request them with a separate API call. So when you request a customer resource you can subsequently request the metafield resources attached to it. Try that and you'll see your metafields using API calls.
Yeah, I just found this out! I'm now using /admin/metafields.json?
metafield[owner_id]=user_id&metafield[owner_resource]=customer
and that's showing the ID's of the resources now. This wasn't very clear in the API docs, but hopefully someone stumbling across this thread will find it useful.