'Invalid Value' Error when Setting Status to "ACTIVE" in New Product Creation via API

shmuel
Shopify Partner
2 0 0

I am working on a feature to create new products in a Shopify environment using GraphQL. While trying to create a product using a mutation, I encountered an unexpected error related to the 'status' field. Even though I've verified that "ACTIVE" is a valid enum value, I'm still receiving an error. 

When I run the following GraphQL mutation:

mutation {
  productCreate(input: {
    title: "DRAWER HUTCH TOWER",
    status: "ACTIVE",
    // ... other options
  })
}

I get this error:

{
    "errors": [
        {
            "message": "Argument 'status' on InputObject 'ProductInput' has an invalid value (\"ACTIVE\"). Expected type 'ProductStatus'.",
            // ...
        }
    ]
}

 

To make sure "ACTIVE" is indeed a valid value, I queried the ProductStatus enum:

 

 

{
  __type(name: "ProductStatus") {
    enumValues {
      name
    }
  }
}

And received:

{
    "data": {
        "__type": {
            "enumValues": [
                {"name": "ACTIVE"},
                {"name": "ARCHIVED"},
                {"name": "DRAFT"}
            ]
        }
    },
    // ...
}

This clearly shows that "ACTIVE" is a valid value, so why am I getting this error?

 

Replies 2 (2)
gsmaverick
Shopify Partner
21 3 3

You probably need to update your URL to explicitly include an API version, see this post for more details: https://community.shopify.com/c/graphql-basics-and/passing-an-enum-in-graphql-variable/m-p/1134872/h...

shmuel
Shopify Partner
2 0 0

I still get the same error event using explicit version, this is the link I have used

https://example.myshopify.com/admin/api/2023-07/graphql.json