Hi Readers,
As discussed in last article we will start develop API Page for integration from #msdyn365bc or #MSDynNAV.
If you want to see other articles in this series please refer here.
API Pages are for integration purpose and cannot be used in the client for users access. There are specific rules need to be followed during development of API Pages.
Update 16/09/2023 -
Now available for Business Central: Suite Engine's API Engine.
Suite Engine's API Engine is a robust tool developers can use to build integrations from within Business Central to any number of external sources.
Highlights:
- Flexible framework for developers to create an endless number of integrations.
- Any API data system is eligible to integrate within Business Central.
- Only basic technical requirements are needed to get started, with no coding necessary.
Suite Engine's solutions simplify business operations by seamlessly integrating Business Central with other essential tools, automating tasks, and delivering real-time insights.
Let's understand What API pages are -
- Pages of the type API are used to create versioned, webhook-supported, OData v4 enabled REST web services.
- This type of page cannot be displayed in the user interface but is intended for building reliable integration services.
- When creating this page type, you must specify a number of properties that provide information for the web service endpoint.
- Use the snippet tpage - Page of type API to get the right template and the list of these properties automatically filled in.
- This page type cannot be extended by creating a page extension object. Instead, you must create a new API by adding a page object.
For our integration demo we will add an PI page that will allow us to read the attachment from business central or write the attachment for business central.
Mandatory Properties for API Pages -
- Specify APIVersion, APIPublisher, APIGroup, EntityName, and EntitySetName for your API page. These properties will affect your custom endpoint.
- Make Sure that ODataKeyFields is set to a GUID Field. If you are using version BC16 or lower then you will need to add GUID Field in your table.
- For Business Central 2020 Wave 2 (BC17) you can utilize the system field from Microsoft as discussed in this article. I think the main reason of adding these fields in every table by Microsoft is to make integration easier.
For our Example we will add two new fields -
- In64BitValue - This variable will be used to key-in Bit 64 value from external application.
- Out64BitValue - This variable will be used to send Bit 64 value to external application.
Also to populate value of Out64bitvalue, we will set that in OnAfterGetRecord using a function as below.
And below are the fields in the API Page that are added.
System ID field need to be added in API Page (or GUID Fields that you used in ODataKeyFields).
In next article we will start testing the customization that we developed.
Stay Tuned. Let me know your views as comment to this article.
Regards,
Saurav Dhyani
Saurav Dhyani
Hi Saurav, thanks for the excellent content, is it possible to add a copy button to your above code such that you can just copy the code and paste it to AL.
ReplyDeleteThe Source Code is in github - https://github.com/postsaurav/ImportAttachment-API
Delete