I spend lot of time to understand ... I had same problem. On development my java application, using official API, first i create product with one (main image), after I trying to add more images with Your error.
Solution is VERY SIMPLE. When You add more than one image, avoid to add ID in json call. (I have my own Java model which reproduce original API and NEVER use "int" => use "Integer" instead, for all keys at model)
BAD:
{
"entry": {
"id": 0,
"mediaType": "image",
"position": 0,
"disabled": false,
"types": ["image", "small_image", "thumbnail"],
"content":{
"base64_encoded_data" : "_9j_4AAQSkZJRgABAQEAYABgAAD__...<cutted_here>",
"type": "image/jpeg",
"name":"pic_name.jpg"
}
}
}
Right way:
{
"entry": {
"mediaType": "image",
"position": 0,
"disabled": false,
"types": ["image", "small_image", "thumbnail"],
"content":{
"base64_encoded_data" : "_9j_4AAQSkZJRgABAQEAYABgAAD__...<cutted_here>",
"type": "image/jpeg",
"name":"pic_name.jpg"
}
}
}
When You read official documentation is NO describe to right way. I've founded solution looking here:
line 509, see : if (isset($entry['id']))
at ./vendor/magento/module-catalog/Model/ProductRepository.php
PHP is looking if ID is set !!!
Alberto