To connect to data, specify OrganizationUrl. The OrganizationUrl should be either the endpoint to your business central account such as https://businesscentral.dynamics.com/abc123/, or it should reference the web services root. Please see Business Central Endpoints for more details on how to specify the OrganizationUrl and which endpoints are available.
If you have multiple companies in your organization, you must also specify the Company to indicate which company you would like to connect to. Company does not need to be specified if you have only one company.
To authenticate to Dynamics 365 Business Central, you may provide the User and AccessKey connection properties. Microsoft recommends these for testing and development purposes, but discourages their use for production environments.
To obtain the User and AccessKey values, navigate to the Users page in Dynamics 365 Business Central and then click on Edit. The User Name and Web Service Access Key values are what you will enter as the User and AccessKey connection string properties. Note that the User Name is not your email address. It is a shortened user name.
Microsoft recommends for production use cases to use OAuth authentication. Below is an explanation of how to connect via OAuth. OAuth requires the authenticating user to interact with Dynamics365. To connect, you will need to register an app in Azure. Below we list the steps on how to register an App on Azure.
Create an Azure App using the New Portal
Log in to https://portal.azure.com.
On the left hand side, select Azure Active Directory, then App Registrations and click the Add button.
In the menu presented, give a name to your app, select app/web api
set the CallbackURL to the appRulesPortal URL (example: http://localhost:8080)
Now go to Keys and create a key for the app. You can select to create a key with a limited duration, or one that never expires. Selecting one that never expires will prevent you from having to create further keys in the future and is recommended.
After the key is saved, a value for the key will be displayed once. Save this value or write it down. You will also need to save the value of the Application Id currently displayed.
Now select required permissions and Add. Under Select an API, choose Business Central.
Once the Dynamics365 app has been added to the required permissions, select it from the menu and under Delegated Permissions, select Access Business Central as organization users.
Save your changes.
Authenticate to Dynamics365 in appRules Portal when creating a new datasource
Set the following connection properties:
OrganizationUrl: The organization url you are connecting to such as https://[organization].crm.dynamics.com.
OAuthClientId: Set this to the application id displayed for the app you created in Azure.
OAuthClientSecret: Set this to the value of the key you created in Azure.
Use the following process to Get your access and refresh tokens
The connector will use the refresh token to obtain a new access token once the current access token has expired. This is generally the best method of configuring OAuth.
Initiate OAuth
REFRESH
OAuth Access Token
Set to the value of the OAuth access token obtained from the endpoint
OAuth Refresh Token
Set to the value of the OAuth refresh token obtained from the endpoint
If you are running Dynamics 365 Business Central on an Azure VM, you can leverage Managed Service Identity (MSI) credentials to connect:
AuthScheme: Set this to AzureMSI.
The MSI credentials will then be automatically obtained for authentication.
Other properties (Proxy...) are detailed in section common properties
Dynamics 365 Business Central supports several different endpoints to connect to data, with the two main categories being the Common Service endpoints, and the Web Services endpoints. Beyond that, each set of endpoints are split into Production and Testing endpoints. Production endpoints require an OAuth connection, whereas Testing endpoints may be connected to via User and AccessKey. Note that both Production and Testing endpoints access and interact with the same data - they just have different restrictions on what authentication methods are allowed.
The OrganizationUrl by default will attempt to resolve to a Common Service Production endpoint if any https://businesscentral.dynamics.com/ URL is specified. However, this may be configured by modifying the EndpointType. In addition, specifying any https://api.businesscentral.dynamics.com/ will override both EndpointType and UseSandbox as the specified OrganizationUrl supplied will be used without alteration.
Common Service endpoints contain the business data associated with Dynamics 365 Business Central. For instance, accounts, sales orders, and sales invoices will all be found on the Common Service.
https://api.businesscentral.dynamics.com/v2.0/{environment name}/api/v1.0
https://api.businesscentral.dynamics.com/v1.0/api/v1.0
https://api.businesscentral.dynamics.com/v1.0/sandbox/api/v1.0
https://api.businesscentral.dynamics.com/v2.0/{tenant id}/{environment name}/api/v1.0
https://api.businesscentral.dynamics.com/v1.0/{tenant id}/api/v1.0
https://api.businesscentral.dynamics.com/v1.0/{tenant id}/sandbox/api/v1.0
Note: The Tenant Id is the id of your tenant in Azure that the Business Central app is available on. This may be obtained by logging into portal.azure.com, selecting your user name, and going to Switch Directory. It may also be found under portal.azure.com, going to Active Directory, and Overview. Environment names may be found under https://businesscentral.dynamics.com/{tenant id}/admin.
Web Service endpoints include anything that has been custom exposed in Dynamics 365 Business Central. This may include KPIs, reports, individual entites, or other feeds. In Dynamics 365 Business Central, click the magnifying glass and search for Web Services to get an idea of what all are exposed by these endpoints.
https://api.businesscentral.dynamics.com/v1.0/ODataV4/
https://api.businesscentral.dynamics.com/v1.0/{tenant id}/ODataV4/
In the 2019 version, the default endpoint resolved to was the Web Services testing endpoint if a https://businesscentral.dynamics.com/ url was supplied to OrganizationUrl. The new default is the Common Service production endpoint. To continue using the Web Services testing endpoint, either set it directly or change the EndpointType to WSTesting.