AL icon indicating copy to clipboard operation
AL copied to clipboard

Installing and uninstalling published add-on extensions - API not working

Open jeffreybulanadi opened this issue 7 years ago • 6 comments

Describe the bug Install and Uninstall extensions using API does not working on the standard business central. Error Returned from API: { "error": { "code": "BadRequest_ResourceNotFound", "message": "Resource not found for the segment 'extensions'. CorrelationId: 8189f5d8-0060-44f5-a2ee-a96cbf74622b." } }

To Reproduce Steps and to reproduce the behavior:

  1. Using a postman try to make a POST request to this link provided from microsoft itself. 'https://api.businesscentral.dynamics.com/v2.0/{environment name}/api/microsoft/automation/v1.0{apiVersion}/companies({companyId})/extensions({extensionId})/Microsoft.NAV.install' Change the following variable:
  • {companyId} = 529fe116-5ae1-48de-b61f-6db9f5666 (https://api.businesscentral.dynamics.com/v2.0/{environment}/Sandbox/api/v1.0/companies)
  • {extensionId} = fa2919fd-bcfb-4237-b976-c8d7a160b13b (i just simple create and published an app to sandbox, upload if production. kindly see the provided screenshot for the extension id.
  • using bearer token authentication.
  • Method should be 'POST'

AL Code to reproduce the issue

Expected behavior It will install-uninstall the extension using API

Screenshots image

image

image

image

5. Versions:

  • AL Language: 4.0.182565
  • Business Central: 15.0.36560.0

jeffreybulanadi avatar Oct 14 '19 02:10 jeffreybulanadi

Hello @dyepri,

I think the problem you came across happens because when constructing the URL, you are using the App Id instead of the Package Id of the extension you are trying to install. The correct way to do it is:

'https://api.businesscentral.dynamics.com/v2.0/{environmentName}/api/microsoft/automation/v1.0/companies({companyId})/extensions({packageId})/Microsoft.NAV.install' .

If unsure what is the packageId in your case, you can find it out by making a GET request against: 'https://api.businesscentral.dynamics.com/v2.0/{environmentName}/api/microsoft/automation/v1.0/companies({companyId})/extensions'.

Note: The difference between the Id and PackageId is that the whereas the Id (App Id) is indeed uniquely identifying each extensions, it is only the Package Id that is unquely identifying different versions of the same extension (i.e. if an extension has multiple versions, they will have the same AppId, but the PackageId will be different) .

Cristina-Msft avatar Oct 14 '19 13:10 Cristina-Msft

Hi @crraita,

This works like a charm. Thanks. Anyways it would be nice if we can ask to update the documentation from microsoft to change the api docs from {extensionId} to {packageId} in order for us to understand it well.

Cheers, dyepri

jeffreybulanadi avatar Oct 16 '19 00:10 jeffreybulanadi

Sure ! 👍 Thanks, dyepri!

Cristina-Msft avatar Oct 16 '19 09:10 Cristina-Msft

@crraita, thanks for details here on ticket,

I tried to use API in the Postman tool but getting errors related to unauthorize access.

I have question-related to access against my credentials, as per blog

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

does that mean I need to have both access

  1. Admin access to a tenant
  2. Superuser permissions under Business central tenant

Thanks in Advance!

chavansachin20 avatar Nov 01 '19 08:11 chavansachin20

Hi @chavansachin20 You need to at least have "D365 EXTENSION MGT" permissions to uinstall or uninstall extensions. Theres no difference in permissions required in the web client or APIs.

henrikwh avatar Nov 01 '19 11:11 henrikwh

Thanks, @henrikwh, I have a SUPER role assigned to me so I'm able to publish an app to Sandbox from VS code. But while using postman getting an error related to authorization.

also API call talk about {environment name} : i have used https://businesscentral.dynamics.com/

where to get companyId , I have extensionId with me but got confunsed against companyId & environment name

chavansachin20 avatar Nov 03 '19 14:11 chavansachin20