Can't Create Product Image Metafields or Private Metafields With GraphQl API

Mertl
Shopify Partner
3 0 1

I am trying to add Metafields to a newly created Product Image through either the privateMetafieldUpsert or the metafieldsSet mutations. The privateMetafieldUpsert mutation returns a "the owner record does not exist" error on the "input" field while the metafieldsSet mutation returns an "invalid id" error with locations "line":5,"column":31 and path "metafieldsSet". Here are the mutation queries being used:

 

 

mutation upsertPrivateMetafield($privateMetafield: PrivateMetafieldInput!) {
  privateMetafieldUpsert(input: $privateMetafield) {
    privateMetafield {
      id
      namespace
      value
      key
    }
    userErrors {
      field
      message
    }
  }
}

//--- variables
"variables": {
  "privateMetafield": {
    "key": "spImageTag",
    "namespace": "SP",
    "owner": "gid://shopify/ProductImage/29576762327118",
    "valueInput": {
      "value": "part.supplementfacts.img",
      "valueType": "STRING"
    }
  }
}
mutation setMetafields($metafields: [MetafieldsSetInput!]!) {
  metafieldsSet(metafields: $metafields) {
    metafields {
      key
      namespace
    }
    userErrors {
      message
      field
    }
  }
}

//--- variables
"variables": {
  "metafields": [
    {
      "key": "spImageTag",
      "value": "part.bottle.img",
      "type": "single_line_text_field",
      "namespace": "SP",
      "ownerId": "gid://shopify/ProductImage/29577150365774"
    },
    {
      "key": "spImageTag",
      "value": "part.supplementfacts.img",
      "type": "single_line_text_field",
      "namespace": "SP",
      "ownerId": "gid://shopify/ProductImage/29577150398542"
    },
    {
      "key": "spImageTag",
      "value": "part.bottle.img",
      "type": "single_line_text_field",
      "namespace": "SP",
      "ownerId": "gid://shopify/ProductImage/29577150300238"
    }
  ]
}

 

 

I've added in a call immediately prior to the mutation calls for the metafields and I can verify those ProductImages exist and that the Ids match.

Reply 1 (1)

fzoccara_sintra
Shopify Partner
3 0 3

Try with newer api versions, I'd the same issues with company gid and using 2023-01 api version I make my day!