Wednesday, December 4, 2024

D365 FO Export package using Rest API

D365 FO Export package.

1.Create the export project in Data Management and add the required data entities to the export project.

Start the process:

2.Trigger the below URL with the required parameters to export the data in package.

  • You can assign an execution ID, otherwise, the system will generate the ID.

URL : 

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

Input parameters:

{
    "definitionGroupId":"<Data project name>",
    "packageName":"<Name to use for downloaded file.>",
    "executionId":"<Execution Id if it is a rerun>",
    "reExecute":<bool>,
    "legalEntityId":"<Legal entity Id>"
}

3.In response, the system will send a 200k response and return the execution ID in the response payload.

4.In job history, you will find the transaction.

Get or Download file:

5.Trigger getExportedPackageURL to retrieve the package, passing the execution ID as an input parameter.

URL : 

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

Input parameters:

{"executionId":"<Execution Id>"}

6.The system will return the temporary blob URL in the value field. By using this URL, you can download the file.
Output:

Get the status:

7. In some scenarios, the data is huge and the system will take some time to process. In such cases, the above step will not work immediately. Before that, we need to check the status of that transaction.

8.To get the status of the transaction, trigger the below URL and pass the execution ID as an input parameter.

URL : 

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

Input parameters:

{"executionId":"<executionId>"}




Keep Daxing!!


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!!