Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello,
I'm trying to add a metafield to one of the products of my store. I'm currently using the sample data provided in the Metafield API documentation:
{
"metafield": {
"namespace": "inventory",
"key": "warehouse",
"value": 25,
"value_type": "integer"
}
}
And the URL i'm sending my POST request to:
/admin/products/#{id}/metafields.json
However I keep getting the following error every time:
{ error: { product: 'Required parameter missing or invalid' },
code: 400 }
Any suggestions/ideas on how to fix this?
Thanks in advance.
Did you try changing the #{id} to be the ID of an actual existing product in your POST?
Yes I did, I intentionally left the placeholder in my original post.
I'm coming up against the exact same issue.
Accessing existing metafields is fine, I can do that no problem, but if I try to add or edit and existing metafield then I get the same 'required parameter missing or invalid' error.
I've tried numerous ways and no luck.
Examples (I've fudged the URL so as not to reveal client data):
URL: https://example.myshopify.com/admin/products/2003472641/metafields/9015105921.json
Method: PUT
Payload: {"metafield": {"id": 9015105921, "value": "test", "value_type": "string" }}
I'm pretty sure it's either not working as it should or the documentation is out of date or incorrect.
I'm coming up against the exact same issue.
Accessing existing metafields is fine, I can do that no problem, but if I try to add or edit and existing metafield then I get the same 'required parameter missing or invalid' error.
I've tried numerous ways and no luck.
Examples (I've fudged the URL so as not to reveal client data):
URL: https://example.myshopify.com/admin/products/2003472641/metafields/9015105921.json
Method: PUT
Payload: {"metafield": {"id": 9015105921, "value": "test", "value_type": "string" }}
I'm pretty sure it's either not working as it should or the documentation is out of date or incorrect.
Hey there, we had exactly the same thing. Turned out that you have to explicitly tell Shopify that you’re sending it up as a JSON object.
Not quite sure on the technicals of that, but I know that's what we had to do. If that still leaves you without the solution let me know and I will see if I can find out more.
Good luck with it! Matt