In Part 1, I went over some of the terminology and tools involved with getting data from Business Central (NAV).
In Part 2, we’re going to go into Business Central and run an API.
The first thing you need to do is get your “extra special secret password” (otherwise known as the Web Service Access Key).
To do this, go into Business Central and navigate to Users:
Select the user you wish to use and click:
Click on the Web Service Access Key field and use control-c to copy the value:
Do NOT click on the edit assist three dots:
If you do, you’ll get this message:
Click No to get out of there.
Copy the key someplace where you can reference it. (I assume that as security-minded folks you keep all your passwords safely in a program like KeePass https://keepass.info/ )
So, now you have a user name and a web security key.
Note: If your computer is set up with the same Windows user that you are using in Business Central, you should not need to do this step, as explained by Microsoft (accessed 2/26/2020):
When users send a request for a web service, they are authenticated according to the credential type that is configured for Business Central Server. To access a web service, users must provide valid credentials for the credential type being used. If Business Central is configured for Windows credential type, then users are automatically authenticated against the Windows account that their computer is running under, and they are not prompted for their credentials. For other credential types, users are prompted to enter a user name and password.https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/web-services-authentication
Finding Our First API – or Web Service
Now that you have your authentication, you need your web service:
Navigate to Web Services:
When you enter this screen, you’ll see several different kinds of object types, such as Codeunits, Pages, and Queries.
We want to keep things simple for our first API so we’re going to use Page — Object ID 16 — Chart of Accounts. Once you identify the line you want, scroll to the right:
After each object, you’ll see different web services on offer: OData v4, OData, and SOAP.
We’re going to work with OData v4. Identify the URL:
As this is a web application, if you hover over the link, you’ll get the hint Open in new browser window:
Go ahead and click.
If your Windows login matches the login to Business Central, you will not be prompted for your user name and password.
If it doesn’t match, use the user name and web services access key you stored securely previously:
To show you that I practice what I preach, I’m going to use my KeePass app to automatically fill in my credentials:
And if everything works, I get JSON key value pairs (in a somewhat unreadable format):
Note that I’ve tried copying the link address – but I don’t always get the results I expect. So, I’ve been clicking and copying from the browser window.
I purposely chose a table that I knew had limited data (especially in CRONUS).
You DO NOT want to click on this directly if you’ve chosen the G/L Entries query and have lots of data.
What do you want to do next? If you answered “work with Postman,” you’re correct.
And that’s the subject of part 3.