update product image using REST api

Solved
Highlighted
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
Highlighted
Shopify Staff
Shopify Staff
1041 140 170

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.

 

Notice; Out of office, replies will be delayed until my return. Thanks!
0 Likes
Highlighted
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?