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

Notifications

Announcements

Community site session details

Community site session details

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

API Pages - multi level response

(0) ShareShare
ReportReport
Posted on by 397
We would like to do an API call that for each customer returns the related Posted Sales Invoice and for each invoice returns the related invoice lines i.e. 3 levels nested. The API should return a response in the following format. How can we do this? 
We've already managed to get to the second level by creating an API page (customers) with a part linked to another API Page (slaes Invoice Header) but how do we get the third level (Sales Invoice Lines)? 
 
{
    "@odata.context": "https://api.businesscentral.dynamics.com/v2.0/......",
    "value": [
        {
            "@odata.etag": ".........",
            "customerNo": "189",
            "name": "TestAcc1",
            "balance": 110.7,
            "balanceDue": 110.7,
            "salesInvoices": [
                {
                    "@odata.etag": ".....",                    
                    "documentNo": "SI000008",
                    "invoiceid": "8893b289-0af5-f011-8405-7c1e525fbab0",
                    "documentdate": "2026-01-19",
                    "amount": 49.2,
                    "remainingAmount": 49.2,
                    "open": true,
                    "salesInvoiceLines": [
                        {
                            "@odata.etag": ".....",                    
                            "documentNo": "SI000008",
                            "lineno": "100000",
                            "itemno": "ABC123",
                            "quantity": 1
                        },
                        {
                            "@odata.etag": ".....",                    
                            "documentNo": "SI000008",
                            "lineno": "200000",
                            "itemno": "ABC456",
                            "quantity": 1
                        }
                    ]
                },
                {
                    "@odata.etag": ".....",                    
                    "documentNo": "SI000008",
                    "invoiceid": "8893b289-0af5-f011-8405-7c1e525fbab0",
                    "documentdate": "2026-01-19",
                    "amount": 49.2,
                    "remainingAmount": 49.2,
                    "open": true,
                    "salesInvoiceLines": [
                        {
                            "@odata.etag": ".....",                    
                            "documentNo": "SI000003",
                            "lineno": "100000",
                            "itemno": "XYZ123",
                            "quantity": 1
                        }
                    ]
                }
            ]
        }
    ]
}
 
I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,075 Super User 2025 Season 2 on at
    AFAIK, BC supports 2 levels and 3rd level will be ignored.
    You have to create a function in codeunit to create that Json format and return.
    Publish that codeunit as WebService and call it.

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,925

#2
YUN ZHU Profile Picture

YUN ZHU 1,006 Super User 2025 Season 2

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 1,000

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans