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 Type | Description |
---|---|
automationCompany resource type | Represents an automationCompany resource type in Dynamics 365 Business Central. |
company resource type | Represents a company resource type in Dynamics 365 Business Central. |
configurationPackages resource type | Represents a configurationPackage resource type in Dynamics 365 Business Central. |
extension resource type | Represents an extension resource type in Dynamics 365 Business Central. |
extensionDeploymentStatus resource type | Represents a extensionDeploymentStatus resource type in Dynamics 365 Business Central. |
permissionSet resource type | Represents a permissionSet resource type in Dynamics 365 Business Central. |
user resource type | Represents a user resource type in Dynamics 365 Business Central. |
userGroup resource type | Represents a userGroup resource type in Dynamics 365 Business Central. |
userGroupMember resource type | Represents a userGroupMember resource type in Dynamics 365 Business Central. |
userPermission resource type | Represents 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.
Number | Name | Kind | Url |
1 | entityDefinitions | EntitySet | entityDefinitions |
2 | companies | EntitySet | companies |
3 | subscriptions | EntitySet | subscriptions |
4 | configurationPackages | EntitySet | configurationPackages |
5 | file | EntitySet | file |
6 | automationCompanies | EntitySet | automationCompanies |
7 | extensions | EntitySet | extensions |
8 | userGroups | EntitySet | userGroups |
9 | users | EntitySet | users |
10 | userGroupMembers | EntitySet | userGroupMembers |
11 | userPermissions | EntitySet | userPermissions |
12 | permissionSets | EntitySet | permissionSets |
13 | extensionUpload | EntitySet | extensionUpload |
14 | extensionDeploymentStatus | EntitySet | extensionDeploymentStatus |
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
コメント