Product Variant Append Media Graphql Mutatation transient failure

tnbnovicell
Shopify Partner
2 0 1

Hi!

 

We're expanding our Product Integration to handle Medias attached to variants. The following scenario fails with this user error: ""Non-ready media cannot be attached to variants"

 

1. Create Product (succeed)

2. Upload Media (succeed)

3. Attach Media to Product (succeed)

4. Attach Product Media to Variant (fails)

 

I suppose the error message makes sense, however this quite troublesome, since we cannot know for sure, when the media is ready in Shopify (without heavy cost to the bucket size). Is there a reason to why the mutation cannot accept the product variant to media attachment even though the media is not yet fully ready yet in Shopify's system? Anyone else found a neat workaround for this?

Replies 2 (2)

dlacom
Shopify Partner
6 0 3

You may want to try using the REST API to do this. You'll be able to combine your steps 2-4 into one API call to upload the image and attach it to a variant, but the downside is that you'll need to do it one image at a time. See the example here https://shopify.dev/docs/api/admin-rest/2023-07/resources/product-image#post-products-product-id-ima...

Tech lead
Material Retail

ShopifyDevSup
Shopify Staff
1357 224 473

Hey @tnbnovicell 

Are you seeing a MediaStatus of UPLOADED or READY?

 

There are examples of how to create products with media as well as variants with media in a single mutation in the documentation, but if you are still seeing issues with media listed as READY, can you post full examples of the steps you are taking so we can take a closer look?

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog