Navigation in Business Central APIs

Introduction


Business Central provides us a standard set of API pages which we can use for performing CRUD Operations on records.

In addition to this it also provides us with “Containments” feature, which lets us fetch records related to a certain record.

Pre-requisites

  • Business Central onCloud or On-Premise.
  • Postman (For Testing)

References

Using Containments and Associations - Business Central | Microsoft Docs

Usage

Go to Web Services.

Click on Actions and download the Metadata for that Web Services.



In case of the “Sales Order API”, the actual sub-page is named salesOrderLines, so the endpoint for Navigation would be {ParentServiceName}{SubPageName} which in this case would be salesOrderssalesOrderLines.



We can see the same in the Metadata document as well.



Use the following format for calling the Containment endpoint - salesOrders(Document ID)/salesOrderssalesOrderLines.



This returns an array, which contains the list of that particular Sales Order’s Lines.

You can create these associations in your own APIs as well by adding a subpage to your API page or Web Service.

Conclusion

Thus we saw how we can use Navigation in Business Central APIs to directly access sub-page data in APIs.

Happy Coding!

Comments

Popular posts from this blog

Using Notifications in Business Central via AL

Actionable Error Messages in Business Central

Configure Gmail SMTP service in Business Central without "Allow Less Secure" setting