Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

importing base64string (api call) as contact image.

(0) ShareShare
ReportReport
Posted on by 10

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. 
pastedimage1647440364046v2.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"
pastedimage1647440430832v4.png
Kind regards
Tim
  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: importing base64string (api call) as contact image.

    Hello,

    I did ask around and this link may be helpfull:

    docs.microsoft.com/.../devenv-checklist-submission-faq

    You can send mail to a mail address if there are issues.

    The people performing approval are most likely at the launch event in Orlando.

    Thanks.

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: importing base64string (api call) as contact image.

    Hello,

    That is new for me. Let me ask around if there is a specific approval process in place and what the requirements are to get into that group.

    Thanks.

  • TimXams Profile Picture
    10 on at
    RE: importing base64string (api call) as contact image.

    Hi Marco,

    Thank you for you answer.

    I tried getting access to the yammer community. But I have to wait for approval.

    It is taking a long time to get approved apparently.

    Do you know anyone who I can contact, to get access this community?

    This is the respons I get if I try to access the community:

    pastedimage1649077238008v1.png

    Kind regards,

    Tim

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: importing base64string (api call) as contact image.

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,020 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,837 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans