Updating product image via REST API results in two images

Hello,

 

I am using Magento CE 2.3.4.

 

I'm trying to update a single entry in a product's media gallery using the REST API. Basically I'm just trying to update the image with a newer image - I don't want to change any other attributes or add a new image.

 

However, when I make the PUT call, instead of updating that media entry ID with the provided information, Magento actually wipes out the metadata for the existing media entry and creates a new media entry for that product with the provided data. I then end up with two entries for the product, one of which points to the old image and the other points to the new image, whose filename is the same as the original with a "_1" appended, and both the old and new images show up on the site.

 

Any idea how to work around this?

 

Existing Data:

[
    {
        "id": 100,
        "media_type": "image",
        "label": "Product 5432 image",
        "position": 0,
        "disabled": false,
        "types": [
            "image",
            "small_image",
            "thumbnail",
            "swatch_image"
        ],
        "file": "/path/to/5432.jpg"
    }
]

API Request:

POST /rest/V1/products/5432/media/100

Payload:

{
   "entry":{
      "id":100,
      "media_type":"image",
      "label":"5432 image",
      "position":0,
      "disabled":false,
      "types":[
         "image",
         "small_image",
         "thumbnail",
         "swatch_image"
      ],
      "file":"",
      "content":{
         "base64_encoded_data":"xxx",
         "name":"5432.jpg",
         "type":"image/jpeg"
      }
   }
}

Resulting record:

[
    {
        "id": 100,
        "media_type": "image",
        "label": "5432 image",
        "position": 0,
        "disabled": false,
        "types": [],
        "file": "/path/to/5432.jpg"
    },
    {
        "id": 101,
        "media_type": "image",
        "label": "5432 image",
        "position": 0,
        "disabled": false,
        "types": [
            "image",
            "small_image",
            "thumbnail",
            "swatch_image"
        ],
        "file": "/path/to/5432_1.jpg"
    }
]