update product image using REST api

Solved
Tourist
4 0 1

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
Highlighted

Success.

Shopify Staff
Shopify Staff
521 67 79

Hey @sefiani,

 

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

 

0 Likes
Highlighted
Tourist
4 0 1

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?

1 Like