Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi
I have created a metafield on my orders. but following the documentation on the API call
Order id
4969826058433
Metafield ID
2337276097
PUT Done to
https://DEVSTORE.myshopify.com/admin/api/2023-01/orders/4969826058433/metafields/2337276097.json
Body Of Postman
{ "metafield":{ "id":2337276097, "value":"Ready for Collection", "type":"single_line_text_field" } }
Error
{
"errors": "Not Found"
}
Solved! Go to the solution
This is an accepted solution.
I am Updating a Metafield. I see that each orders Metafield has an Unique id that is generated. That was my issue. Got is resolved.
I see your call is to create one. PUT method to update once it is populated
Managed to get it working in Rest API.
Just Migrated to GraphQL which I can use and update multiple Metafields at the same time.
For anybody reading this. It is not the Metafield ID where you create the Metafield. Also if a Metafield value don't exit you have to first create it via API in that order.
To test get the Metafield ID generated here is your admin portal If the order has Metafield data populated. To get it via API you have to query the orders metafields to get the ID.
/orders/{orderid}/metafields.json
Hi DeonSmit,
Just to confirm are you creating or updating an existing metafield? Could you try the same API call but with curl to rule out some issue on Postmans side, eg:
curl -d '{"metafield":{"namespace":"my_fields","key":"purchase_order","type":"single_line_text_field","value":"Ready for Collection"}}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2023-01/orders/4969826058433/metafields.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"
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
This is an accepted solution.
I am Updating a Metafield. I see that each orders Metafield has an Unique id that is generated. That was my issue. Got is resolved.
I see your call is to create one. PUT method to update once it is populated
Managed to get it working in Rest API.
Just Migrated to GraphQL which I can use and update multiple Metafields at the same time.
For anybody reading this. It is not the Metafield ID where you create the Metafield. Also if a Metafield value don't exit you have to first create it via API in that order.
To test get the Metafield ID generated here is your admin portal If the order has Metafield data populated. To get it via API you have to query the orders metafields to get the ID.
/orders/{orderid}/metafields.json