Hello Shopify Support,
I’m encountering an issue when trying to create a metafield for a customer using the Admin API. Below is the code I’m using:
const metafield = new shopify.rest.Metafield({session: session});
metafield.customer_id = 8415805440167;
metafield.namespace = “discounts”;
metafield.key = “special”;
metafield.value = “yes”;
metafield.type = “single_line_text_field”;
console.log(‘metafield’, metafield);
await metafield.save()
.then((res) => console.log(‘res3’, res))
.catch((err) => console.log(‘err’, err));
The metafield is not being saved, and the request falls into the catch block. However, the error message returned is not very informative. The customer ID I’m working with is 8415805440167.
What I’ve already checked:
-
The API credentials and access scopes are correctly configured.
-
The customer ID exists and is valid.
-
The namespace, key, value, and type follow the API documentation.
Despite this, the metafield is not being created successfully.
Could you please help me understand what might be going wrong? Specifically:
-
Are there any additional requirements or limitations when creating metafields for customer objects?
-
Should I be using
owner_resourceandowner_idinstead ofcustomer_id?
Any guidance would be appreciated.
Thank you,
Kemal Bekcan