cancel
Showing results for 
Search instead for 
Did you mean: 

add exist image to simple product

add exist image to simple product

Hi,

I'm a c# dev and the new user of Magento API. Currently I'm working with Magento ver. 2.3.3

My case is:

I'm creating a configurable product (I wont paste the entire product creation process for a simple message/topic) by API <-- in this proces I'm adding a new image by CatalogProductAttributeMediaGalleryManagementV1CreatePostBody, then in the different place of code I want to create a simple product with added earlier image. I have all information, but without base64. I'm adding a image by MediaGalleryEntries list:

var productImage = new REST.JsonObject.Request.CatalogProductRepositoryV1SavePostBody.MediaGalleryEntries();
productImage.id = image.id;
productImage.media_type = image.media_type;
productImage.label = image.label;
productImage.disabled = image.disabled;
productImage.position = image.position;
productImage.types = image.types;
productImage.file = image.file;
productImage.content = new REST.JsonObject.Request.CatalogProductRepositoryV1SavePostBody.Content();
productImage.content.type = GetMimeType(image.file.RemoveBeforeLast("/").RemoveBeforeFirst("."));
productImage.content.name = image.file.RemoveBeforeLast("/");
product.media_gallery_entries.Add(productImage);
(base64_encoded_data = null)

and then do PUT request on simple product, I receive 

{"message":"The image content must be valid base64 encoded data."}

Question:
How to add EXIST image in magento to product without sending image file every time.

 

Why I don't want to send the file data again?

--> optimization, photos on my side are in binary data, why I have to send it twice?