All things Shopify and commerce
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"}]}}]}
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.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025