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

Heiko_Woywodt
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

 

product with variantsproduct with variantsGet all product imagesGet all product imagesGet a single product image by idGet a single product image by id

0 Likes

Hello 
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:

https://help.shopify.com/en/api/reference/products/product#create-2019-10

https://help.shopify.com/en/api/reference/products/product-image#show-2019-10

  

If helpful then please Like and Accept Solution. Free Website Review and advice for sale from Hire us
Shopify Conversion Experts | Shopify Private App | Custom Theme Development | Custom Modifications In To Shopify Theme | Shopify SEO | Digital Marketing | Site Speed Optimization | Performance Site Audit
For Quick Chat Whats app | Email: pallavi@oscprofessionals.com | Skype : oscprofessionals-87
0 Likes
Heiko_Woywodt
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. 

 

Product Image Rest call with fields parameterProduct Image Rest call with fields parameterProduct Image Rest call without fields parametersProduct Image Rest call without fields parameters

0 Likes
CodeclockerDev
New Member
30 0 0

Hello!

Did you ever get a response on this? I am running into the same issue and seems nobody either from shopify directly or a community member has not responded.

0 Likes