Skip to main content

Microsoft Dynamics NAV 2018 - API Part 3 - Consuming API.

Hi Readers,

We already have two posts about NAV 2018 API listed below -

Microsoft Dynamics NAV 2018 - API Part 1.

Microsoft Dynamics NAV 2018 - API Part 2 - Configure API.


In this article, we will see how we can consume these APIs. For the Demo, I will use Google Chrome App called Postman. I am sure there are great developers out there who know how to consume it but I just wanted to test how it is consumed.

If you are interested in the small demo using Postman then please go further otherwise, i am sure you know how to consume these APIs.



1. Download Google Chrome App "Postman" using this link.

2. Launch App from Google Chrome window.


3. Close first popup/splash screen in-app. We can see that there are so many options (15) to choose from. But I was able to find out that NAV API only support 2 options -  GET and POST.

GET   is used to read data from NAV API.
POST is used to write data in NAV using APIs.


4. I am choosing one of the API from 44 APIs that we see in the last post. Lets select paymentMethods as highlighted below.



Base URL - http://localhost:11048/DynamicsNAV110/api/beta
Name - paymentMethods

So URL To use in POSTMAN - http://localhost:11048/DynamicsNAV110/api/beta/paymentMethods

5. Let's try to use GET and compare data with NAV. In NAV Entity is Page - 5486 "Payment Methods Entity".



6. Now let's try to use the POST statement and check data in NAV.
If we choose to post and try to click Send it will not work obviously as it will require some data (at least primary key), as shown below.


Now I am comfortable with JSON, you can choose other forms based on your comfort and assigned value to - code and description. The code is code in API and Description is displayName in API.

In postman select the Body tab, select raw and you can select any of 7 formats. I will select JSON and enter values for both parameters and then click send.

** Just to remember all these are case sensitive.



7. Let's check data in NAV table. Here is what we got in NAV using the POST.


Hope you find the information useful and will be able to consume API In your environment.

In Next article, we will try to create a New simple API. If you have some thoughts please let me know.

Let me know your views.

Regards,

Comments

  1. Hello Saurav,

    i have followed your above blog but getting error when i enter this URL on Post man and click-Sand

    URL: http://localhost:7064/DynamicsNAV110/api/beta/customers


    {"error":{"code":"Internal_CompanyNotFound","message":"Cannot process the request because the default company cannot be found. You can specify a default company in the service configuration file, or specify one for each tenant, or you can add a query string in the form of \"company=[name]\". You can see the available companies by accessing the default OData web service, Company. For more information, see \"OData Web Services\" in Help."}}

    Kindly suggest?

    ReplyDelete
    Replies
    1. Either in Service Tier Specify the name of the default company and restart the service to update the parameter or you can also add the company name in URL -
      http://localhost:7064/DynamicsNAV110/api/beta/customers/"Company=Demo"

      Delete

Post a Comment

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

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 -