Where can I get the ID value of metafileds when registering for the product?
{
“input”: {
“metafields”: [
{
“description”: “”,
“id”: ???,
“key”: “use1”,
“namespace”: “custom”,
“type”: “multi_line_text_field”,
“value”: “meta11111”
}
],
…
}
Where can I get the ID value of metafileds when registering for the product?
{
“input”: {
“metafields”: [
{
“description”: “”,
“id”: ???,
“key”: “use1”,
“namespace”: “custom”,
“type”: “multi_line_text_field”,
“value”: “meta11111”
}
],
…
}
Hi Weap0n7,
If you’re creating a new metafield for a product, you don’t need to provide an id value as this will be generated by Shopify once the metafield is created. However, if you are updating or retrieving an existing metafield, you would need the id value to reference the correct metafield.
To get the id values of existing metafields for a product, use the metafields connection on the Product type via the GraphQL API:
{
product(id: "gid://shopify/Product/1234567890") {
metafields(first: 10) {
edges {
node {
id
key
}
}
}
}
}
Hope this helps!