Using Containments in Business Central OData Web Service

by Jaromír Chaloupka — August 18, 2020

An overview of using Containments in Dynamics Business Central OData V4 Web Service.

Facebook Twitter E-mail LinkedIn

As you maybe already know it's possible to publish some page in Dynamics Business Central as a web service. It's pretty easy but what if you would like to publish a page containing a subpage and you would like to publish it as OData V4 Web Service and in JSON format? Then you will need to know something about Using Containments and Associations.

Publish Sales Order Card page as OData V4 web service

Below you can find some example how to publish Sales Order Card page with Sales Order Lines subpage as OData V4 Web Service in JSON format.

Firstly, you need to publish Page 42 Sales Order as web service:

Sales Order web service

After that you should be able to open link for OData V4 web service, in our case it's http://insider:7048/BC/ODataV4/Company('My%20Company')/SalesOrder and you should see JSON formatted text with data related to Sales Order. Unfortunately, there is no information related to Sales Order Lines.

In order to see data for Sales Order Lines you need to modify the URL address for your published web service with $expand parameter as following: http://insider:7048/BC/ODataV4/Company('My%20Company')/SalesOrder?$expand=SalesOrderSalesLines

According to Microsoft Docs link above, you can also use the following link which will show you data for the specific Sales Order (data for header and lines): http://insider:7048/BC/ODataV4/Company('My%20Company')/SalesOrder(Document_Type='Order',No='101001')/SalesOrderSalesLines

About the Author

Jaromír Chaloupka

Jaromír Chaloupka

Dynamics NAV/365 BC Developer at Prodware

me[at]webdew[dot]cz

D365 BC Functional Consultant Azure Fundamentals