Skip to main content

Notifications

Announcements

No record found.

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

Odata Download Blob

(0) ShareShare
ReportReport
Posted on by 14
Hi, 
i have a custom table that has various fields, one of them is a blob containing a pdf file.
The table has an API page that is exposed with an odata web service
 
I use visual Studio pro and i would like to consume the web service and manage to download the file in the blob.
I downloaded Odata Connected service extension.
I manage to query the table,
I manage to get the Blob Selflink (that should contain the link to the file) but how to save it locally ?
Any suggestion ? 
 
B. regards
Fabrizio Fiammenghi
  • GrisuX Profile Picture
    GrisuX 14 on at
    Odata Download Blob
    thanks for reply.
     
    I published the page using  the "web services" page in  Business central.
     
    From Visualstudio pro, in C# i mangae to connect to the web service and i manage to get record fields
     
    var serviceRoot = "http://bc.it:7058/BC220_TEST_PUB_CAP/ODataV4/";
    var context = new BC.NAV(new Uri(serviceRoot));
    context.BuildingRequest += Context_BuildingRequest;
    var data = context.GestionFileApi.Execute();
     
    the data variable containe the collection of the record of that page
     
    once i get the record i need, the filed 
    "Blobfile"  contains the and the property 
    BlobFile.SelfLink it seems contains the uri of the blob file
     
    i need to save it in a local file 
     
    is this the right way ?
    how to create the stream and save it ?
     
    there is a better way ?
     
    many thanks
    Fabrizio
     
     
     
     
  • GrisuX Profile Picture
    GrisuX 14 on at
    Odata Download Blob
    Sorry, but probably i mis explained my self.
    From AL Side everything is ok, i manage to create the blobl, save in the table and download from the table.
     
    What i need is to be able to download the file from outside Business central, via web services
    Other info in the next reply
     
    Fabrizio 
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,595 Super User 2024 Season 2 on at
    Odata Download Blob
    Hi, there is a simple way to convert it to encoded text (Base64 String) in BC, and then after getting it, you convert it to PDF in your language.
    Some simple examples:
    How to import/create item picture from encoded text (Base64 String)
    https://yzhums.com/39193/
     
    How to convert Image (item picture) to encoded text (Base64 String) via AL
     
    Hope this helps.
    Thanks.
    ZHU
  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    Odata Download Blob
    What programming language are you using to consume the API page?
    C# or something else?

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! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans