Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

productUpdateMedia doesn't work, no errors thrown

Solved

productUpdateMedia doesn't work, no errors thrown

Emanuele
Shopify Partner
2 1 0

I have 3 images in a product created with the REST product creation, and I want to update the "alt" property images with the productUpdateMedia mutation, but it doesn't work. Following the request and the response:

 

Emanuele_0-1728044800830.png

 

note the "media : null" in the response.

Curiously, if I try to use the productCreateMedia the operation work fine:

 

Emanuele_1-1728044900377.png

 

Then I tried to update, with the productUpdateMedia mutation, this new image created with productCreateMedia, and the operation still doesn't work.

 

Have you any idea to solve this problem?

 

Thank you.

 

 

 

 

Accepted Solution (1)

Emanuele
Shopify Partner
2 1 0

This is an accepted solution.

It was simple.....

The image id variable is a ProductImage id, not a MediaImage id. It's not possible get the number of the ProductImage and build the MediaImage.

Example

if the image id is 0123456789 I can build the gid product image in this way:
gid://shopify/ProductImage/0123456789

but if I need to refer to the media image I cannot build it like:

gid://shopify/MediaImage/0123456789

 

The media image will be different, to discover it it is necessary query the product and catch it, like something of the following:

Emanuele_0-1728053273513.png

the id hightlighted in red is the MediaImage, this is to be used for productUpdateMedia mutation.

 

 

View solution in original post

Reply 1 (1)

Emanuele
Shopify Partner
2 1 0

This is an accepted solution.

It was simple.....

The image id variable is a ProductImage id, not a MediaImage id. It's not possible get the number of the ProductImage and build the MediaImage.

Example

if the image id is 0123456789 I can build the gid product image in this way:
gid://shopify/ProductImage/0123456789

but if I need to refer to the media image I cannot build it like:

gid://shopify/MediaImage/0123456789

 

The media image will be different, to discover it it is necessary query the product and catch it, like something of the following:

Emanuele_0-1728053273513.png

the id hightlighted in red is the MediaImage, this is to be used for productUpdateMedia mutation.