Happening now | Office Hours: Customizing Your Theme With Moeed | Ask your questions now!
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

REST API "PUT" unable to update Product metafield

REST API "PUT" unable to update Product metafield

chcsep
Shopify Partner
92 4 36

I have tried everything but keep getting "Bad request" when I try to update a product metafield.

 

I have retrieved the Metafields for the product and selected the Metafield ID for the metafield I'm trying to update (it has an existing value)

 

My URL is in this format:

https://[API_key]@[storename].myshopify.com/admin/api/2023-04/products/[ProductID]/metafields/[MetafieldID].json

My CURL request is in this format:

-X PUT 
-H "Content-Type: application/json"
-d { "metafield": { "id": [MetafieldID], "value": "MyText" } )

And I've tried many variations, but I always get the unhelpful response "HTTP/1.1 400 Bad Request"

 

Does anyone know what I am doing wrong??

 

Edit: I was able to get a workaround by deleting the old metafield value, which permitted me to re-add the metafield to the product using the PUT command on products/[productid].json

Replies 0 (0)