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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Business Central API v2.0 Create Attachment request JSON

(0) ShareShare
ReportReport
Posted on by 103

Hi Business Central Community,

I am trying to create an attachment for a Purchase Invoice. As I understand from the documentation (https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_attachment_create). My JSON should look like:

{
    "parentId": <the ID from the Purchase Invoice>,
    "parentType: "Purchase Invoice",
    "fileName": <for example 'document.pdf'>,
    "attachmentContent": <'stream'???>
}

What is supposed to be "stream", which they referred to in the documentation? I tried to encode in Base64 string but that doesn't work.

I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    99,090 Super User 2026 Season 1 on at
  • tl2022 Profile Picture
    103 on at

    Hi Yun, thanks for linking the documentation! I got it to upload the file.

    One question remains though. I see that the attachment is in Incoming Document Files. How do I make it go to Attachments section?

    Screenshot_5F00_20221130_5F00_143033.png

  • Verified answer
    YUN ZHU Profile Picture
    99,090 Super User 2026 Season 1 on at

    Hi, An attachment in the Business Central standard API is defined as an Incoming Document (table 130)

    So if you need Attachments section, you need to customize your own API.

    pastedimage1669849909093v1.png

    More details: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-custom-api

    Hope this helps.

    Thanks.

    ZHU

  • tl2022 Profile Picture
    103 on at

    Thanks Yun, I will take a look at custom API. Similarly, if I want to post Purchase Invoice to Posted Purchase Invoice, do I also need custom API?  

  • Verified answer
    YUN ZHU Profile Picture
    99,090 Super User 2026 Season 1 on at

    Hi, yes.

    Hope the following helps.

       

    Or, you can use OData V4 Bound Action.

    More details: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-creating-and-interacting-with-odatav4-bound-action

    Hope this helps.

    Thanks.

    ZHU

  • Syed Sajjad Hasan Profile Picture
    10 on at

    Hi ZHU,

    Tried to follow all the steps in the first and second links mentioned by you. I am able to create and patch the file. Just wanted to know whether I convert the file to Base 64 encoding for sending when using C#?

  • Suggested answer
    YUN ZHU Profile Picture
    99,090 Super User 2026 Season 1 on at

    HI, Sorry I haven't tried it, but it looks like it might work.

    https://stackoverflow.com/questions/25919387/converting-file-into-base64string-and-back-again

    pastedimage1670544594867v1.png

    Hope this helps.

    Thanks.
    ZHU

  • tl2022 Profile Picture
    103 on at

    Hi Syed, I'm using Java, but I didn't need to do the base64 encoding. Here is what I do in Postman and what it translates to in C# RestSharp:

    pastedimage1670545135716v2.png

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March 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,949 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,064 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 559 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans