What Developers Need to Know about Navision Microsoft Dynamics 365 Business Central API


What Developers Need to Know about Navision Microsoft Dynamics 365 Business Central API


What is Navision API?


Microsoft Dynamics NAV (formerly Navision) is an enterprise resource planning (ERP) software solution designed for small and medium-sized businesses. One of the key features of Dynamics NAV is its API (Application Programming Interface), which allows developers to integrate the software with other systems and automate certain processes.


The NAV API consists of a set of Web services and a set of programming interfaces that can be used to access the data and functionality of the NAV system. The Web services are based on the Simple Object Access Protocol (SOAP) standard and use the XML format to exchange data. The programming interfaces include the C/AL (C/AL Language) and the C/SIDE (Client/Server Integrated Development Environment) that allows developers to create and modify NAV objects such as forms, reports, tables, and codeunits.


What does Navision API offers?

The NAV API can be used for a wide range of tasks, including:


  • Importing and exporting data: The NAV API allows developers to import and export data from the NAV system, such as customer and vendor information, sales and purchase orders, and inventory data. This can be used to synchronize data between the NAV system and other systems, such as a website or a CRM system.
  • Automating processes: The NAV API can be used to automate certain processes within the NAV system, such as creating and posting invoices, creating and releasing purchase orders, and creating and posting journal entries. This can be used to reduce the need for manual data entry and improve the efficiency of the business.
  • Creating custom reports and dashboards: The NAV API can be used to create custom reports and dashboards that provide insights into the data stored in the NAV system. This can be used to gain a better understanding of the business and make more informed decisions.
  • Building custom integrations: The NAV API can be used to build custom integrations between the NAV system and other systems, such as a website, a CRM system, or an e-commerce platform. This can be used to streamline the flow of data and automate certain processes between the systems.


Hmm,Give Me an Example?

Here's an example of C/AL code that consumes a NAV Web service using the NAV API:                                                

Url : Text
reqText : Text
WebServReqMgt : Codeunit : Web Service Request Mgt.
ReqBodyOutStream : OutStream
ReqBodyInStream : InStream
Username : Text
Password : Text
RespBodyInStream : InStream
ResponseXmlDoc : DotNet : System.Xml.XmlDocument.’System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′
TempBlob : Record : TempBlob                  
Url := 'http://localhost:8080/MyService';
// save request text in instream
TempBlob.”Primary Key” := 1;
TempBlob.Blob.CREATEOUTSTREAM(ReqBodyOutStream);

ReqBodyOutStream.WRITE(reqText);
TempBlob.Blob.CREATEINSTREAM(ReqBodyInStream);

// run the WebServReqMgt functions to send the request
WebServReqMgt.SetGlobals(ReqBodyInStream,Url,Username,Password);
WebServReqMgt.DisableHttpsCheck;
WebServReqMgt.RUN;

// get the response
WebServReqMgt.GetResponseContent(RespBodyInStream);
ResponseXmlDoc := ResponseXmlDoc.XmlDocument;
ResponseXmlDoc.Load(RespBodyInStream);
MESSAGE(ResponseXmlDoc.InnerXml);

                                                  


Ok,How Can We Create an Endpoint to consume Data Or execute code in Navision?

Creating a web service in Microsoft Dynamics NAV (formerly Navision) involves several steps. Here's an overview of the process:


  1. Open the Microsoft Dynamics NAV Development Environment and create a new codeunit.
  2. Define the web service methods that you want to expose. These methods should be defined as procedures or functions in the codeunit. Each method should have a clear name and a clear purpose, and should be well-documented.
  3. Decorate the methods with the Web Service attribute, indicating that the methods should be exposed as web services.
  4. Publish the codeunit as a web service. You can do this by right-clicking on the codeunit in the Object Designer and selecting "Publish" from the context menu. You can then select the web service methods that you want to expose.
  5. Create a new endpoint in NAV for the web service. This can be done in the NAV Development Environment by navigating to the "Web Services" page and clicking on "New" to create a new endpoint. You will need to specify the name of the endpoint, the type (SOAP or OData), and the URL of the web service.
  6. Test the web service using a tool such as SoapUI to ensure that it is working as expected.
  7. Once the web service is deployed, it can be consumed by external systems by sending requests to the specified endpoint URL.


It is important to note that the NAV API is a powerful tool that can be used to automate and streamline many different processes within the NAV system, but it is also a complex tool that requires a certain level of technical expertise to use effectively. Developers should be familiar with the NAV system, as well as the programming languages and tools that are used to interact with the API.


Additionally, it is important to thoroughly test any custom code or integrations that are built using the NAV API, to ensure that they are working as expected and do not cause any issues in the NAV system.


Also keep in mind that  the specifics of this process may vary depending on the NAV version, setup and the tools used to perform this task.



In conclusion, the NAV API is a powerful tool that allows developers to automate and streamline certain processes within the NAV system, as well as building custom integrations between NAV and other systems.

Previous Post Next Post