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    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searching for the error i figured out the issue was due to - Design change in NA

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.