Product Image REST-API: "variant_ids": [] is empty for images assigned to variants

Shopify Partner
3 0 0

If one or more images of a product have been added to its variants, then "variant_ids": [] in the response remains empty. See the screenshots below.

How to reproduce:

- create a product

- add an image to the product

- create variants and add the image to the variants

- GET /admin/api/2019-10/products/#{product_id}/images.json and/or GET /admin/api/2019-10/products/#{product_id}/images/#{image_id}.json


image.pngproduct with variantsimage.pngGet all product imagesimage.pngGet a single product image by id


We have understand your problem varient_id:[]. because of if image source is null or invalid for varients then varient_id will be null.
For more details we can go through below link:


Want to modify or incorporate custom changes on store, Hire us.
If helpful then please Like and Accept Solution .
Skype : oscprofessionals-87
Custom Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | Digital Marketing | Site Speed Optimization | Web Development
Shopify Partner
3 0 0

Thanks for your answer! I do not understand why the image source should be null or invalid for variants.
The product and the variants are created via the shopify backend. Also the image upload and the image assignment to the variants was done via the shopify backend manually.


In the meantime I have found a proof that this is bug and also a workaround for it. ;-)


If you execute the call without the field parameter (.../admin/api/2019-10/products/4298011246627/images.json) then "variant_ids" : [] is empty/null .

If you execute the call with the fields parameter (...admin/api/2019-10/products/4298011246627/images.json?fields=id,product_id,position,variant_ids) then the assigned variants to the image are listed in "variant_ids" : [30972269428771,30972269494307] are listed. See the screenshots below. 


image.pngProduct Image Rest call with fields parameterimage.pngProduct Image Rest call without fields parameters