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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Business Central API Integration with Third-Party Software Using POST for BLOB Field

(11) ShareShare
ReportReport
Posted on by 131
Hi Everyone, 
 

I am currently working on integrating Microsoft Dynamics 365 Business Central with a third-party application. As part of this integration, the third-party software needs to send a file to Business Central via an API (Page, Codeunit, or Query). This file will be stored in a field of type BLOB.

At present, I have exposed a Page API, and they are able to send the file using a PATCH request. However, the third-party system requires a POST request instead of PATCH.

Could anyone advise on the recommended approach to support POST requests for uploading BLOBs to Business Central? Would it be more appropriate to implement this through a custom API Page or a Codeunit, and how should the BLOB handling be structured?

Thank you in advance for your support!

 

Best Regards,

Suketu Piprotar
I have the same question (0)
  • Suggested answer
    Kamal Khakhkhar Profile Picture
    3,428 on at
    Hii there ,
    If the third-party can't support base64, create a proxy in Azure to transform binary to base64 before sending to BC.
    also you can create a API Pages , Codeunit , table as per requirement .
     
    If you found your reference/Answer . please mark it answered.
     
    Thank You.
    Kamal Khakhkhar
  • Suggested answer
    Jainam M. Kothari Profile Picture
    17,024 Super User 2026 Season 1 on at
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    9,128 Super User 2026 Season 1 on at

    Hi Suketu,

    You're absolutely right to explore alternatives to PATCH, especially when the third-party system mandates a POST request for file uploads. BC’s standard API pages typically support PATCH for updating BLOBs, but you can absolutely support POST by designing a custom API Page or Codeunit.

    Let’s break it down:

     

    1. Why PATCH works by default and POST doesn’t
    Standard API Pages in BC are designed for entity updates, which is why PATCH is the default method for modifying BLOB fields. POST is reserved for creating new records, and doesn’t natively support BLOB streaming unless explicitly handled.

     

    2. Recommended approach: Custom API Page + Codeunit
    To support POST for BLOB uploads:

    • Create a custom API Page that exposes the record with the BLOB field
    • Add a Codeunit with a procedure that accepts a Text or InStream parameter
    • Use CreateInStream and CreateOutStream to handle the BLOB field
    • Trigger the Codeunit via an action on the API Page, or expose it as a separate endpoint

    Example structure:

    al
    procedure UploadFileViaPost(var Rec: Record "YourTable"; FileContent: Text)
    var
        OutStream: OutStream;
    begin
        Clear(Rec.YourBlobField);
        Rec.Modify(true);
        Rec.YourBlobField.CreateOutStream(OutStream);
        OutStream.WriteText(FileContent);
        Rec.Modify(true);
    end;
     

    You can also use HttpContent and HttpRequestMessage if you're building the integration from BC outward.

     

    3. Alternative: Use Media or MediaSet fields
    If the file is an image or document, consider using Media or MediaSet fields instead of BLOB. These are optimized for file handling and support POST natively via the standard API.

     

    4. Key considerations

    • Ensure the BLOB field is marked with DataClassification = ToBeClassified
    • Use DelayedInsert = true on the API Page to allow POST before record creation
    • Validate stream closure to avoid errors like “Read called with an open stream”
     

    Helpful references:

    Handling BLOB fields on APIs – Stefano Demiliani
    Posting JSON Data in BLOB via POST – Stack Overflow
    BC API Overview – Microsoft Learn


    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

  • Suggested answer
    YUN ZHU Profile Picture
    101,995 Super User 2026 Season 1 on at
    Hi, a simple example, hopefully it will give you some hints.
    Dynamics 365 Business Central: Using OData V4 unbound action (Codeunit API?) to communicate and exchange data seamlessly
     
    Thanks.
    ZHU
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,177 Super User 2026 Season 1 on at
    You can support POST for BLOB upload using a custom API Codeunit with InStream/OutStream. Here's a short AL example:
     
    codeunit 50100 BlobUpload
    {
        [ServiceEnabled]
        procedure UploadFile(FileName: Text; Base64Content: Text)
        var
            RecRef: RecordRef;
            InStr: InStream;
            OutStr: OutStream;
            TempBlob: Codeunit "Temp Blob";
        begin
            TempBlob.CreateOutStream(OutStr);
            OutStr.WriteText(Base64Content);
            TempBlob.CreateInStream(InStr);
            TempBlob.ToRecord(SomeTargetRecord); // Your table with BLOB field
            SomeTargetRecord.CalcFields("Your BLOB Field");
            SomeTargetRecord."Your BLOB Field".CreateInStream(InStr);
            // Save the BLOB content as needed
            SomeTargetRecord.Modify();
        end;
    }
     
     
     
    This allows third-party apps to POST base64 files into BC via a Codeunit.
     
     
  • Gerardo Rentería García Profile Picture
    27,280 Most Valuable Professional on at

    Hi, good day
    I hope this can help you, and give you some hints.

    Dynamics 365 Business Central: handling BLOB fields on APIs – Stefano Demiliani

    Best Regards
    Gerardo

  • CU16060844-1 Profile Picture
    2 on at
    If a third-party system specifically requires a POST, a custom Codeunit exposed as a web service is often a cleaner approach, especially when handling file uploads and BLOB streams. I myself was recently looking for alternatives to photo editing software on Mac and came across https://setapp.com/app-reviews/snapseed-alternative-for-mac which is a good example of how specialized comparison guides can help you evaluate your tool choices when building integrations around external platforms. They are very helpful and may be able to get your request to work. I would add that for Business Central, the Codeunit also gives you more control over validation, error handling, and future extensibility than the standard API page.
  • Suggested answer
    Grigorios Mavrogeorgis Profile Picture
    2,554 Super User 2026 Season 1 on at
    Hi Suketu,
    the PATCH thing isn't really a limitation, it's just OData semantics — you PATCH the media or $value endpoint because the record already exists, POST is for creating. So if their system only does POST, don't fight that endpoint.
    Better to expose the BLOB on your API page as a base64 text field, and let them POST the whole record as JSON with the file content sitting in that field. On insert you decode the base64 back into the BLOB. POST works naturally then, because it's an insert not an update.

    Other way is a bound action — those get called with POST anyway — and you read the content from the request body in a codeunit. I'd go the API page plus base64 field route myself, easier for them to consume.
    One thing that bites — base64 grows the payload about a third, and there's request size limits, so for big files it gets messy.
     
    Glad to help - follow up if anything is unclear.  
    ►  If this solved it, marking it verified helps others too.      
    Regards,
    Grigorios Mavrogeorgis
    Business Central Consultant & AL Developer

    Work: Gmsoft Limited
    Blog:  insidebusinesscentral
    LinkedIn: linkedin.com/in/gregorymavrogeorgis

     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,960 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,299 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,131 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans