Automation APIs for Dynamics 365 Business Central SaaS

Dynamics 365 Business Central

Hi readers.
Last week, we discussed the Standard API and Basic operations of APIs in Business Central.
For more information, see Standard API for Dynamics 365 Business Central SaaS (Get, Post, Patch, Delete and Basic query parameters – filter, orderby, select…)

In this post, I will share another out-of-the-box API in Business Central, Automation APIs.
Automation APIs provide capability for automating company setup through APIs. Once the tenants have been created, the automation APIs can be used, in order to hydrate the tenant – to bring the tenant up to a desired state. Usually this involves creating a new company on the tenant, running RapidStart packages, installing extensions, adding users to user groups and assigning permission sets to users.

Delegated admin credentials and Dynamics 365 Business Central users with permissions, can call the APIs.

The following table provides an overview of the available Automation APIs resource types on a Dynamics 365 Business Central tenant. (FM MS DOCS)

Resource TypeDescription
automationCompany resource typeRepresents an automationCompany resource type in Dynamics 365 Business Central.
company resource typeRepresents a company resource type in Dynamics 365 Business Central.
configurationPackages resource typeRepresents a configurationPackage resource type in Dynamics 365 Business Central.
extension resource typeRepresents an extension resource type in Dynamics 365 Business Central.
extensionDeploymentStatus resource typeRepresents a extensionDeploymentStatus resource type in Dynamics 365 Business Central.
permissionSet resource typeRepresents a permissionSet resource type in Dynamics 365 Business Central.
user resource typeRepresents a user resource type in Dynamics 365 Business Central.
userGroup resource typeRepresents a userGroup resource type in Dynamics 365 Business Central.
userGroupMember resource typeRepresents a userGroupMember resource type in Dynamics 365 Business Central.
userPermission resource typeRepresents a userPermissions resource type in Dynamics 365 Business Central.

Pre-requisites

1. Endpoints for the Automation APIs:
https://api.businesscentral.dynamics.com/v2.0/user domain name/environment name/api/microsoft/automation/v2.0/

For Example: My test environment
Tenant ID (user domain name): d8f36038-1f93-4543-affc-5dc92b6ee871
Environment name: Sandbox03
Endpoints: https://api.businesscentral.dynamics.com/v2.0/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox03/api/microsoft/automation/v2.0/

2. Authentication: Basic authentication
Username and web service access key as password.
You can get web service access key from User Card.

Update (2021/12/14): Using OAuth to connect Business Central APIs and Web Service in Postman

3. Test Tool: Postman
The Collaboration Platform for API Development
Download: https://www.postman.com/

Get Automation APIs list

The Automation APIs are provided by Microsoft and we can use them out-of-box.

1. Set GET request and enter your Endpoint URL.
For Example:
https://api.businesscentral.dynamics.com/v2.0/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox03/api/microsoft/automation/v2.0/

2. In Authorization tab, set type to Basic Auth, and enter your Username and web service access key as password.

3. Choose Send.

Then you can get the list of Automation APIs.

Up to now, BC17.1 2020/11/30, there are a total of 14 Automation APIs in Business Central.
Note: The upper and lower case letters in the URL must match exactly.

NumberNameKindUrl
1entityDefinitionsEntitySetentityDefinitions
2companiesEntitySetcompanies
3subscriptionsEntitySetsubscriptions
4configurationPackagesEntitySetconfigurationPackages
5fileEntitySetfile
6automationCompaniesEntitySetautomationCompanies
7extensionsEntitySetextensions
8userGroupsEntitySetuserGroups
9usersEntitySetusers
10userGroupMembersEntitySetuserGroupMembers
11userPermissionsEntitySetuserPermissions
12permissionSetsEntitySetpermissionSets
13extensionUploadEntitySetextensionUpload
14extensionDeploymentStatusEntitySetextensionDeploymentStatus

Some Examples

1. Get extensionDeploymentStatus: Retrieves the properties of an extensionDeploymentStatus object for Dynamics 365 Business Central.
https://api.businesscentral.dynamics.com/v2.0/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox03/api/microsoft/automation/v2.0/companies(6325c2d6-c92a-eb11-846e-000d3ac98e05)/extensionDeploymentStatus

Business Central:

Test Video:

2. extensions: Get and Uninstall extension.
Get: https://api.businesscentral.dynamics.com/v2.0/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox03/api/microsoft/automation/v2.0/companies(6325c2d6-c92a-eb11-846e-000d3ac98e05)/extensions

Uninstall:
Post: https://api.businesscentral.dynamics.com/v2.0/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox03/api/microsoft/automation/v2.0/companies(6325c2d6-c92a-eb11-846e-000d3ac98e05)/extensions(bc82297a-b839-4634-b1c9-0a27e6463027)/Microsoft.NAV.uninstall

3. automationCompany Resource Type: Create a new company
Get: https://api.businesscentral.dynamics.com/v2.0/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox03/api/microsoft/automation/v2.0/companies(6325c2d6-c92a-eb11-846e-000d3ac98e05)/automationCompanies

Create a new company:

Post: https://api.businesscentral.dynamics.com/v2.0/d8f36038-1f93-4543-affc-5dc92b6ee871/Sandbox03/api/microsoft/automation/v2.0/companies(6325c2d6-c92a-eb11-846e-000d3ac98e05)/automationCompanies

Test Video: This process will take a relatively long time.

Since the usage is similar to the Standard API, I won’t do much testing again, but check out another blog on the Standard API if you’re interested.
Standard API for Dynamics 365 Business Central SaaS (Get, Post, Patch, Delete and Basic query parameters – filter, orderby, select…)

Find out more about automation APIs from Microsoft Docs.

END

Hope this will help.

Thanks for your reading.

ZHU

コメント

Copied title and URL