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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

API Attachments on Journal Gen Line

(4) ShareShare
ReportReport
Posted on by 457
Hi 
On BC SAAS latest release i want to use API to attach a incoming document on a Gen, Jnl Line (This is also created by API),

I don't know which page or code unit to add in web services , or is there any standard endpoint available for same,

please help. do i need to expose any object to OData web services or not.
I have the same question (0)
  • Suggested answer
    Sumit Singh Profile Picture
    10,078 on at
    BC provides a standard API for managing attachments, which are internally represented as Incoming Documents (Table 130).
    Create Attachment Endpoint
    You can use the following endpoint to attach a document:
    POST /businesscentralPrefix/companies({companyId})/attachments
    Request Body Example:
    {
      "parentId": "GUID of the Gen. Journal Line",
      "parentType": "Journal",
      "fileName": "invoice.pdf",
      "attachmentContent": "base64-encoded-file-content"
    }
    • parentId: The system ID of the General Journal Line.
    • parentType: Use "Journal" for General Journal Lines.
    • attachmentContent: The file content encoded in Base64 [1] [2].
    Note: The file must be uploaded as a Base64 string. No need to expose custom objects unless you need more control or metadata.
    How to Get the Journal Line ID
    If you're creating the General Journal Line via API, the response will include the id (GUID) of the line. Use this as the parentId in the attachment API.
    Do You Need to Expose Any Page or Codeunit?
    No, if you're using the standard API. The attachments endpoint is already available in the v2.0 API and supports GET, POST, PATCH, and DELETE operations for attachments[1].
    However, if you want to:
    • Attach documents to custom entities
    • Add additional metadata
    • Trigger business logic (e.g., validations or workflows)
    Then you must expose a custom codeunit or page via OData or create a custom API page.

    Alternative: OData V4 Unbound Actions
    If you prefer OData or need to perform complex logic (e.g., linking to posted entries), you can:
    • Create a Codeunit with procedures
    • Expose it as an OData V4 unbound action
    • Call it from external systems
    References
    [1] GET attachments - Business Central | Microsoft Learn
    [2] Business Central API v2.0 Create Attachment request JSON
    [3] Work with incoming documents - Business Central | Microsoft Learn

    Note: This response was created in collaboration with Microsoft Copilot to ensure clarity and completeness. I hope it helps to some extent.
    Mark the Answer as Verified if this is Helpful.
     
  • Suggested answer
    DAnny3211 Profile Picture
    11,397 on at

    Hello,

    Thank you for your question.

    In the latest release of Business Central SaaS, attaching an incoming document to a General Journal Line via API is not supported through a standard endpoint out of the box. However, there are a few approaches you can consider:

    Recommended Approach:

    1. Expose the Relevant Page via OData
      To enable attachment functionality via API, you will likely need to expose a custom page or codeunit through OData web services. The standard General Journal Line page does not include attachment capabilities by default.

    2. Use the Incoming Document Attachments Table
      You can interact with the Incoming Document Attachments table (Table 133) and link it to the journal line using the appropriate keys. This may require a custom API page or codeunit to handle the logic.

    3. Create a Custom API Page
      If your scenario involves creating both the journal line and the attachment via API, consider building a custom API page that:

      • Accepts the journal line data.
      • Accepts the document (e.g., as a media field or blob).
      • Links the document to the journal line using internal references.
    4. Use the Media or MediaSet Data Types
      For file uploads, use Media or MediaSet fields in your custom API page to handle incoming documents. Ensure the page is properly exposed and published in the Web Services page.

    5. Security and Permissions
      Ensure that the Entra Application or user making the API call has the necessary permissions to access and modify both the journal lines and the attachment records.

    If this response helps resolve your issue, please consider marking it as accepted so it may assist others with similar requirements.

    Best regards.

  • Suggested answer
    Sohail Ahmed Profile Picture
    11,136 Super User 2025 Season 2 on at
    There’s no standard API to attach documents directly to General Journal Lines. You’ll need to create a custom API page that handles file upload (using a Media or BLOB field), store it as an Incoming Document, then link it to the journal line using the Incoming Document Entry No. field.
     
    ✅ Mark this as the verified answer if helpful.
     
     
  • Suggested answer
    techreviews.digital Profile Picture
    376 on at
    In Business Central, there is no solution available to support document attachment in the General Journal Line. However, with customization, it is achievable; a customized field can be created for attaching the documents. The same field will be required to be created on the posted journal line, so the user will be able to view the attachments after posting the transactions as well. 
     
    I hope it will resolve all your concerns.
     
    Best Regards,
    Sheikh Muhammad Jawad
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,390 Super User 2025 Season 2 on at
     
    No, not out of the box unfortunately.
    You will have to make a customization if you want this functionality.
     
    BR
  • Suggested answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at
    Hi, hope the following can 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
    RockwithNav Profile Picture
    8,600 Super User 2025 Season 2 on at

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans