web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

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

Get Media/Blob type file using API

(3) ShareShare
ReportReport
Posted on by 24
Hi all,
 
I am unable to download file when click on blob type file link appears in response of api 
here is the Table 
table 50040 "Digital Signed Invoices"
{
    DataClassification = ToBeClassified;
 
    fields
    {
        field(1; "Document No."; code[50])
        {
            DataClassification = ToBeClassified;
        }
        field(2; "Signed Invoice/Cr Memo"; Blob)
        {
            DataClassification = ToBeClassified;
        }
        field(10; "VBA No."; Code[50])
        {
            DataClassification = ToBeClassified;
        }
        field(11; "Bank Account"; Code[20])
        {
            DataClassification = ToBeClassified;
        }
    }
 
    keys
    {
        key(Key1; "Document No.")
        {
            Clustered = true;
        }
    }
 
    var
        myInt: Integer;
 
    trigger OnInsert()
    begin
 
    end;
 
    trigger OnModify()
    begin
 
    end;
 
    trigger OnDelete()
    begin
 
    end;
 
    trigger OnRename()
    begin
 
    end;
 

}
//API PAGE
page 80001 "Signed Invoice API"
{
    //RM-31Jan2026
    APIGroup = 'SWPortal';
    APIPublisher = 'SW';
    APIVersion = 'v2.0';
    ApplicationArea = All;
    Caption = 'signedInvoiceAPI';
    DelayedInsert = true;
    EntityName = 'signedInvoice';
    EntitySetName = 'signedInvoices';
    PageType = API;
    SourceTable = "Digital Signed Invoices";
 
    layout
    {
        area(Content)
        {
            repeater(General)
            {
                field(documentNo; Rec."Document No.")
                {
                    Caption = 'Document No.';
                }
                field(signedInvoiceMedia; Rec."Signed Invoice Media")
                {
                    Caption = 'Signed Invoice/Cr Memo';
                }
                // field(signedInvoiceCrMemo; Rec."Signed Invoice/Cr Memo")
                // {
                //     Caption = 'Signed Invoice/Cr Memo';
                // }
            }
        }
    }
    // trigger OnAfterGetRecord()
    // var
    //     DigiSignCod: Codeunit "DigiSign Blob to Media";
    // begin
    //     DigiSignCod.Run();
    // end;
}
i am getting this reponse when click on @datamedialink
{"error": {"code": "RequestDataInvalid","message": "Request data is invalid."}}
I have the same question (0)
  • Suggested answer
    Dhiren Nagar Profile Picture
    1,651 on at
    Hi,
     
    From where you are trying to call this API? Postman, Power Automate, any other apps?
     
    Also can you show how the value gets stored in the Blob? Like you are uploading normal file in blob or you converted it into Base64 before saving etc.
     
    Regards,
    Dhiren.
  • Suggested answer
    OussamaSabbouh Profile Picture
    8,716 on at
    Hello,
     
    This error occurs because Business Central APIs cannot stream/download files from a Blob field—the @odata.mediaReadLink only works with Media or MediaSet fields; exposing a Blob on an API page results in an invalid stream endpoint and returns RequestDataInvalid. The standard solution is to store the file in a Media field (or use Document/Incoming Document Attachments), copy the Blob content into it via streams, and expose that Media field on the API page; then the generated media link will download correctly (with proper authentication).
     
    Regards,
    Oussama Sabbouh

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,913

#2
YUN ZHU Profile Picture

YUN ZHU 1,084 Super User 2025 Season 2

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 1,064

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans