Staged Uploads Create Error

Topic summary

A developer encounters an error when creating staged uploads for bulk product mutations. The error message indicates that “BULK_MUTATION_VARIABLES” is not a valid resource type, as the API expects values like TIMELINE, PRODUCT_IMAGE, VIDEO, etc.

Root Cause Identified:

  • The mimeType parameter is incorrectly set to file.type (likely a standard file MIME type)
  • For bulk operations using bulkOperationRunMutation, the mimeType must be “text/jsonl” specifically

Solution Provided:

  • Reference the Shopify bulk import documentation for detailed implementation guidance
  • Change mimeType from file.type to "text/jsonl"
  • The filename parameter can be a general name representing the operation (e.g., “bulk_op_products”) rather than the actual file name

Context: The developer is using Shopify CLI with a Node.js app framework and attempting to upload a JSONL file for bulk product creation.

Summarized with AI on November 24. AI used: claude-sonnet-4-5-20250929.

Hello,

I am having an issue with my app and am not sure where I am making a mistake.

When creating a staged upload I receive the following error:

Error: GraphQL error: Variable $input of type [StagedUploadInput!]! was provided invalid value for 0.resource (Expected “BULK_MUTATION_VARIABLES” to be one of: TIMELINE, PRODUCT_IMAGE, COLLECTION_IMAGE, SHOP_IMAGE, IMAGE, MODEL_3D, VIDEO)

My mutation looks as follows:

const STAGED_UPLOADS_CREATE = gql`
  mutation stagedUploadsCreate($input: [StagedUploadInput!]!) {
    stagedUploadsCreate(input: $input) {
      stagedTargets {
        resourceUrl
        url
        parameters {
          name
          value
        }
      }
      userErrors {
        field
        message
      }
    }
  }
`;

and I call the mutation as follows:

const [stagedUploadsCreate] = useMutation(STAGED_UPLOADS_CREATE);

  const handleSubmit = async () => {
    let { data } = await stagedUploadsCreate({
      variables: {
        input: [
          {
            resource: "BULK_MUTATION_VARIABLES",
            filename: file.name,
            mimeType: file.type,
            httpMethod: "POST",
          },
        ],
      },
    });

It looks like the staged upload is expecting an image, but I would like to upload a jsonl for a bulk mutation of product create.

If anyone had any pointers that would be greatly appreciated!

I used the Shopify CLI to build the frameworks of the node app. (Version 2.5.0)

1 Like

Please look at “how bulk importing data works” in the Shopify API docs. Everything is explained in detail. The error is due to the value you assign to mimeType. The docs says:

mimeType: The media type of the file to upload. To use bulkOperationRunMutation, the mimeType must be “text/jsonl”.

In your code, you’re passing file.type.

Bonus: since this is a bulk operation, you can define a general name to represent the entire operation, such as “bulk_op_products”. You don’t need to use file.name.

1 Like