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...
Unanswered

Uploading attachments via soap

(0) ShareShare
ReportReport
Posted on by 5

I have been unable to find any documentation that describes how uploading attachments can be done via SOAP.

Is this even possible?

Is SOAP being phased out?

Michael

I have the same question (0)
  • Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    You are talking about MIME for web services. You can read more about this here:

    www.soapui.org/.../

    Thanks.

  • Crenshaw Profile Picture
    5 on at

    Thank you for your reply, but this is not what I'm asking for. I mean more specificly in conjunction with BC. How do I set up a service in BC that accepts attachments. I need to call this service from a PHP script via SOAP.

    Thank you

    Michael

  • Binesh Profile Picture
    7,887 on at

    Hello,

    It can be possible by sending/receiving base64 format.

  • Genie Cetas Profile Picture
    472 on at

    Hello,

            Attachments can be uploaded via SOAP services in BC. This can be done by base64 conversion, If you upload any documents in BC it will be stored in "Document Attachment" table so just convert this attachment into base64 and store it to a "Big Text" variable and by consuming this big text variable you can access the document.

            Here I have attached an example, please refer it.

            1) If you need to read the attachments from BC SOAP Service follow this method

            procedure Attachements(var DocAttachments: BigText)

            var

                 Rec_DocumentAttachment: Record "Document Attachment";

                 TempBlob: Codeunit "Temp Blob";

                 Base64: Codeunit "Base64 Convert";

                 Ostream: OutStream;

                 Istream: InStream;

                 Base64Str: Text;

            begin

                 Clear(Base64Str);

                 Rec_DocumentAttachment.Reset();

                 if Rec_DocumentAttachment.FindSet() then begin

                       TempBlob.CreateOutStream(Ostream);

                        Rec_DocumentAttachment."Document Reference ID".ExportStream(Ostream);

                        TempBlob.CreateInStream(Istream);

                        Base64Str := Base64.ToBase64(Istream);

                        Evaluate(DocAttachments, Base64Str);

                 end;

            end;

            2) If you need to upload document from PHP script and need to store the document in BC via SOAP Service then follow this method. Just convert the attachment to base 64 and pass it to the SOAP service

            procedure Attachements(DocAttachments: BigText)

            var

                  Rec_DocumentAttachment: Record "Document Attachment";

                  TempBlob: Codeunit "Temp Blob";

                  Base64: Codeunit "Base64 Convert";

                  RecRef: RecordRef;

                  Ostream: OutStream;

                  Istream: InStream;

                  Base64Str: Text;

            begin

                  Base64Str := Format(DocAttachment);

                  TempBlob.CreateOutStream(Ostream);

                  Base64.FromBase64(Base64Str, Ostream);

                  TempBlob.CreateInStream(Istream);

                  RecRef.GetTable(//Table to which you need to upload the document);

                  Rec_DocumentAttachment.SaveAttachmentFromStream(Istream, RecRef, FileName);

            end;

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

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 566 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 347 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 327 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans