I am trying to call productOptionUpdate API for my store and getting error

I am trying to call productOptionUpdate API for my store and getting error

Ankit_soni
Shopify Partner
2 0 0

API Request:
curl -X POST \
> https://xyz.myshopify.com/admin/api/2024-04/graphql.json \
> -H 'Content-Type: application/json' \
> -H 'X-Shopify-Access-Token: xyz' \
> -d '{
> "query": "mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!]) { productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }",
> "variables": {
> "productId": "gid://shopify/Product/8274219860276",
> "option": {
> "id": "gid://shopify/ProductOption/10495573262644",
> "position": 1,
> "name": "Size",
> "values": ["749766 302|14", "749766 302|13.5", "749766 302|15", "749766 302|13", "12", "13", "14"]
> }
> }
> }'

please let me know if I am missing anything.

API Response :
{"errors":[{"message":"Variable $option of type OptionUpdateInput! was provided invalid value for values (Field is not defined on OptionUpdateInput)","locations":[{"line":1,"column":40}],"extensions":{"value":{"id":"gid://shopify/ProductOption/10495573262644","position":1,"name":"Size","values":["749766 302|14","749766 302|13.5","749766 302|15","749766 302|13","12","13","14"]},"problems":[{"path":["values"],"explanation":"Field is not defined on OptionUpdateInput"}]}}]}


Reply 1 (1)

JuneN
Shopify Partner
145 6 43

Hi @Ankit_soni 
It seems that in the data declared in variables you have an additional field in the JSON called "values": ["749766 302|14", "749766 302|13.5", "749766 302|15", "749766 302 |13", "12", "13", "14"]
When checking Shopify's documentation, we can see that field is not supported in arguments "option"
You can find more details in the reference link: https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productOptionUpdate?language=cURL

I trust this proves beneficial for you.

 

JuneN_0-1717003591406.png

 

If you find my suggestion helpful, please give it a like or mark it as a solution!
And discover more approaches to:
Streamline invoicing process Boost sales with labels & badges Add social proofs & create FOMO
Or get valuable updates and private deals regarding Shopify here.