Hello all,
I'm stuck with importing a image to a contact in BC by using an API call.
I made a codeunit that I can as a webservice.
In this codeunit I use a bigtext parameter that holds the base64string of the image.
When i'm trying to preform my call I get the following error:
"message": "The media object could not be loaded because it is not a valid image type, such as JPEG, GIF, or PNG.
I make an outstream of the bigtext that holds the base64 string. I put this in a blob so I can get it as an instream and add it to the media type:
var
instream: InStream;
outstream: OutStream;
tmpblob: Codeunit "Temp Blob";
Base64: Codeunit "Base64 Convert";
...
tmpblob.CreateOutStream(outstream);
photo.Write(outstream);
tmpblob.CreateInStream(instream);
lContact.image.ImportStream(instream, lContact."No." + '.jpg', 'image/png');
Does anyone know what I'm doing wrong?
If I add the mime type 'image/png' it makes the record put it shows the following as image:
"Geen voorbeeld beschikbaar voor type media-inhoud application/octet-stream"
translated : "No preview available for media type application/octet-stream"
Kind regards
Tim