Skip to main content

Notifications

Announcements

No record found.

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

Business Central API, convert base64 string to blob and save

(1) ShareShare
ReportReport
Posted on by 8
I created new table with blob field and API page for this table. Now I want to intercept POST request and convert base64 string to blob and save the record. Is there anyway to accomplish this? Or any better method for saving file in business central, custom made table from API request
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,942 Super User 2024 Season 2 on at
    Business Central API, convert base64 string to blob and save
    Hi, here is a good example, I hope it can give you some help.
     
    Thanks.
    ZHU
  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,081 Super User 2024 Season 1 on at
    Business Central API, convert base64 string to blob and save
    Hi,
     
    You can try this procedure when you are getting Base64 text from API url.
        local procedure ConverBase64Text(FileContent: text)
        var
            BaseConvert: Codeunit "Base64 Convert";
            TempBlob: Codeunit "Temp Blob";
            OutStr: OutStream;
            RecRef: RecordRef;
        begin
            if FileContent = '' then
                exit;
            RecRef.Open(Database::<TargetTable>);
            RecRef.GetTable(<TargetTable>);
            TempBlob.CreateOutStream(OutStr);
            BaseConvert.FromBase64(FileContent, OutStr);
    
            TempBlob.ToRecordRef(RecRef, <TargetTable>.FieldNo(<BlobField>));
            RecRef.SetTable(<TargetTable>);
            RecRef.Close();
        end;
     
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 13,116 Most Valuable Professional on at
    Business Central API, convert base64 string to blob and save
    Hi
    I hope this can help you and give you some hints. 
    BR
    GR

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans