Skip to main content

#msdyn365bc - How Do I Develop a Custom API Page?

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.

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

Comments

Popular posts from this blog

Welcome - Microsoft Dynamics 365!

Hi All, In this article we will discuss the new introduced member of Dynamics Family. Yes you heard it correctly, one more new member with Name "Microsoft Dynamics 365" . #ProjectMadeira   #Dynamics365

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

NAV 2013 Credential Type - How to Use?

Hi all, Please do these activities when you have time, its a long activity and i would suggest do all activities in one go. So be clam and lets start. For NAV 2013 R2 Refer Here. For NAV 2016 Steps have been Reduced Please Refer Here. I have installed NAV 2013 and its work great with my windows credentials. I was checking the service console (Microsoft Dynamics NAV Administration) in NAV 2013 and found out that Credentials Type have multiple Options.