Error when updating metafields on a product using Celigo Flow

Error

{“errors”:{“key”:[“must be unique within this namespace on this resource”]}}

Solution

You can use the Product API to update or create a metafield when you call PUT /products/PRODUCT_ID.json

{
  product: {
    metafields: [
      { id: 12345, value: "" }, // update a metafield
      { key: "", value: "", type: "single_line_text_field", namespace: "global" } // create a new metafield
    ]
  }
}

But after you save a product you don’t get the metafields, so you need to call first 

/metafields.json?metafield[owner_id]=PRODUCT_ID&metafield[owner_resource]=product

Leave a comment

Your email address will not be published. Required fields are marked *