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

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
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,696 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,091 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 12,183 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans