Skip to main content

Notifications

Business Central forum
Suggested answer

Odata Download Blob

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
Categories:
  • 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 68,242 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 32,744 Moderator on at
    Odata Download Blob
    What programming language are you using to consume the API page?
    C# or something else?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,186 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,996 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans