FROM CACHE - en_header

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,

Accepted Solution (1)

Accepted Solutions
SBD_
Shopify Staff
Shopify Staff
1098 146 220

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.

 

Scott | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)
SBD_
Shopify Staff
Shopify Staff
1098 146 220

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.

 

Scott | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

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