A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Shopify doc on metafields:
https://help.shopify.com/en/manual/custom-data/metafields?st_source=admin&st_campaign=metafields_foo...
As seen in the image the user can add custom metafields to the products, how can I create new products and set metafields? How do I access them? I can not see anything on /product api, is there another api im missing?
Solved! Go to the solution
This is an accepted solution.
Yes, this is expected behaviour. Refer to this page to learn how to manage metafields:
https://shopify.dev/docs/apps/custom-data/metafields/manage-metafields
To learn more visit the Shopify Help Center or the Community Blog.
So I figured out how to set the metafield property with put request: {"product":{"id":632910392,"metafields":[{"key":"Colors","value":"newvalue","type":"single_line_text_field","namespace":"custom"}]}}
But if the field has an existing value then I get the following error when i try to update the value.
Key: must be unique within this namespace on this resource
This is an accepted solution.
Yes, this is expected behaviour. Refer to this page to learn how to manage metafields:
https://shopify.dev/docs/apps/custom-data/metafields/manage-metafields
To learn more visit the Shopify Help Center or the Community Blog.
Thanks for the reply, it helped me solve my issue. It is not REST but that's fine. I found this graphql mutation to solve my specific case: https://shopify.dev/docs/api/admin-graphql/2023-04/mutations/metafieldsset. For future developers, that could be interested 🙂