update product image using REST api

Solved
sefiani
Tourist
9 0 3

Hello i am new in developping shopify apps

i am trying to update the image of product using the REST api

following the doc  to update the image of product we should create a put request

PUT /admin/api/2020-01/products/#{product_id}/images/#{image_id}.json
{
  "image": {
    "id": 850703190,
    "position": 2,
    "alt": "new alt tag content"
  }
}

 but i want to update the image it self by doing

PUT /admin/api/2020-01/products/#{product_id}/images/850703190.json
{
  "image": {
    "id": 850703190,
    "src": "my_custom_link"
  }
}

 but it's seems not working, i receive no error and the image is not updated, is there anyway to update the image product without deleting the original image and adding the new image.

thks,

0 Likes
SBD_
Shopify Staff
Shopify Staff
1089 147 199

This is an accepted solution.

Hey @sefiani,

 

The image content can't be updated, you'll need to remove it and add a new one.

 

0 Likes
sefiani
Tourist
9 0 3

thanks for the answer, so to emulate the replace i have  also to take position, alt tag and variants ids from the original image and put it in the new image, that right?

vitorrodrigues
New Member
1 0 0

hi SBD_ 

you say that the image content can't be updated and you add a link to the api documentation

but i don't see on the documentation any reference that the image content can't be updated...

could you please clarify this ?

thanks

0 Likes