Tuesday, December 3, 2024

Import package in D365 using Rest API.

Import package to D365 using Rest API.


1. Before importing the package, we have to upload it into the blob. by triggering the below URL to get the Azure Write URL. You need to pass the UniqueFileName.

URL : 

POST : {Resource}/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.GetAzureWriteUrl

Input parameters : 

{
    "uniqueFileName":"<string>"
}


2.It will return a 200 OK response with the AzureWriteURL.

3.Copy the URL from the previous step's response and paste it into a new request. 
4.I have used Postman for this process. So In headers, add the required key and value; otherwise, it will throw an error.

Key   : x-ms-blob-type
Value : BlockBlob

5.While triggering this, use the PUT method. Under binary, upload the file and click send.

6.If the file is successfully added to the temporary blob URL, the system will return a 201 Created status.

7.Create an import project and add the required data entities.

8.After this, trigger the ImportFromPackage URL. The required parameters should be passed.

URL : 

POST: {Resource}/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.ImportFromPackage

Input parameters : 

{
    "packageUrl":"URL from 1st step",
    "definitionGroupId":"Import Data project name",
    "executionId":"<string>",
    "execute":<bool>,
    "overwrite":<bool>,
    "legalEntityId":"<string>"
}

9. The system will return a 200 OK response and an execution ID.

10. Go to job history and you will find a new transaction.

11. Once it is processed, you will find the data in the staging and main tables.


Keep Daxing!!

No comments:

Post a Comment