cancel
Showing results for 
Search instead for 
Did you mean: 

API: upload product delete images

API: upload product delete images

Hello,

 

I upload all products with the mediaGallery (all images).

Works fine, but:

 

When I send a put, to update the complete product, and there was already the same images, he delete all images.

Send I again the put, the images are set and display

Send I again the put, the images are deleted

Send I again the put, the images are set and display

Send I again the put, the images are deleted

...

 

So did I need to clean this first? I want to overwrite the images ... also when the images are exactly the same ... but this seems a delete on the server

 

Thank you!

 

 

4 REPLIES 4

Re: API: upload product delete images

I see now in the response:

if no images are exists before I update:

        {
            "attribute_code": "image",
            "value": "/D/H/DH-V40_2.jpg"
        },
        {
            "attribute_code": "small_image",
            "value": "/D/H/DH-V40_small_2.jpg"
        },
        {
            "attribute_code": "thumbnail",
            "value": "/D/H/DH-V40_thumb_2.jpg"
        },

if the images are exists:

        {
            "attribute_code": "image",
            "value": "no_selection"
        },
        {
            "attribute_code": "small_image",
            "value": "no_selection"
        },
        {
            "attribute_code": "thumbnail",
            "value": "no_selection"
        }

What mean "no_selection"? The put is exactly the same

Re: API: upload product delete images

By default, No Selection means Product hasn't any image associated, If a product has the image assigned then they will display a value of product image name. 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: API: upload product delete images

Ok, but is has 3 images.

 

This is the response, when I try to add new images.

The JSON is too big to post here, but it include always all 3 images ... but without ID of the image.

 

Re: API: upload product delete images

I get the same thing, from what I can see you have 3 solution as workaround.

 

1. Either check if images exists, I use the url below to get sku and image names and then remove from my request the existing image.

 

rest/V1/products/?fields=items[sku,media_gallery_entries[file]]&searchCriteria[currentPage]=1&searchCriteria[pageSize]=10

 

 

2. Send a put request with sku and media_gallery as empty array before, it will delete all the images so when you send the complete product again it will work.

 

3. Try and send images tourl below instead

/V1/products/{sku}/media