Skip to content

Magento2 – What is the best way to remove and add an image in magento using rest API?

For an SKU, I have multiple images. Every time I change something related to the SKU, I do a PUT. But before that I also DELETE the images using in a loop

https://<magentoInstance>/rest/all/V1/products/<mySKU>/media/<imageIDs>

Only the first image is getting deleted in this way.

For others the API is giving me "Product cannot be saved... " and does not delete.

So what is the best way to DELETE (all the images) and then POST new images. I PUT the product and then POST the images. Is this correct? Will there be any caching issues?