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

Custom Payload in Business Central API

(4) ShareShare
ReportReport
Posted on by 32
Hi All,
 
I have a requirement that needs BC to provide a payload that's unusual from standard API page.
 
So, my third party application will need to pass json payload that looks like this:
 
I am thinking of using API page but doesn't have capability to have parts inside parts right?
If i were to use web services and publish codeunit, the third party must send a text format instead of jsonobject.
 
 
can help me how to achieve this requirements or any reference
 
Thanks
I have the same question (0)
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,148 Super User 2025 Season 2 on at
    Why don't you use JSON OBJECT & JSON Array to create your JSON Body 
  • Suggested answer
    DAnny3211 Profile Picture
    11,397 on at

    Hello,

    Thank you for your question.

    You're correct that standard API pages in Business Central do not natively support deeply nested JSON structures (i.e., parts within parts). The API page model is designed for flat or moderately nested data and does not handle complex hierarchical payloads like the one you've described.

    Recommended Approach:

    1. Use a Codeunit with a Custom Web Service
      To handle complex JSON payloads, the most flexible and reliable method is to:

      • Create a codeunit that exposes a procedure accepting a Text or JsonObject parameter.
      • Publish the codeunit as a SOAP or OData web service.
      • Parse the incoming JSON manually using AL's JsonObject, JsonArray, and JsonToken types.

      This allows you to fully control how the payload is interpreted and mapped to internal data structures.

    2. Accept Raw JSON as Text
      If the third-party system cannot send a JsonObject, you can accept the payload as a Text parameter and parse it using JsonObject.ReadFrom(Text) within your codeunit.

    3. Avoid API Pages for Deep Nesting
      As you've noted, API pages are not suitable for this use case due to their limitations in handling nested collections. They are best used for standard CRUD operations with simple structures.

    4. Security and Validation
      Ensure that your codeunit includes proper validation, error handling, and authentication (e.g., via OAuth2 or API keys) to protect the endpoint.

    5. Alternative: Azure Function or Middleware
      If the payload structure is fixed and complex, consider using an Azure Function or middleware service to receive the payload, transform it into a format Business Central can consume, and then forward it via a simpler API call.

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

    Best regards.

  • Suggested answer
    YUN ZHU Profile Picture
    95,548 Super User 2025 Season 2 on at
    Hi, hope the following helps.
    Business Central 2025 wave 1 (BC26): Overloaded JsonObject data type GetValue method (New methods access properties and array elements for JSON)
     
    Thanks.
    ZHU

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,151

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans