Parag Chapre

Export data from Dynamics 365 HR via Rest API

Spread the love

In this article, We will see how to export data from Dynamics 365 HR via Rest API.

Dynamics 365 HR/ F&O  supports two APIs.

  1. The Data management framework’s package API.
  2. The recurring integrations API.

Both APIs support both data import scenarios and data export scenarios. The following table describes the main decision points that you should consider when you’re trying to decide which API to use.

Decision pointRecurring integrations APIData management framework’s package API
SchedulingScheduling in Finance and Operations appsScheduling outside Finance and Operations apps
FormatFiles and data packagesOnly data packages
TransformationSupport for Extensible Stylesheet Language Transformations (XSLT) if the data file is in XML formatTransformations that are external to the system
Supported protocolsSOAP and RESTREST
Service typeCustom serviceOpen Data Protocol (OData) action

Technologies used

This tutorial uses the following technologies:

  • Dynamics 365 Human Resources – The master data source for workers that will be exported.
  • Power Automate – The technology that provides orchestration and scheduling of the recurring export.
  • DMF package REST API – The technology that is used to trigger the export and monitor its progress.
  • FTP or Azure storage – The destination for the exported workers.

Overview of Integration

Register an application in Azure for Dynamics 365 HR

This the first step where we have to register an application in Dynamics 365 HR.

  1. Login to Azure portal
  2. Create an app registration
  3. Create a secret key.
  4. Provide an app permission for Dynamics 365 for Talent and other application.
  • Note down the client id, tenant id and secret key.
  • Next step is to add client id in Dynamics 365 HR.
  • Login to Dynamics 365 HR and go to Azure Active Directory applications.
  • Create a new record and add client id and the user id who has a system administrator access.

Create a data export project in Human Resources

In Human Resources, create a data export project that exports workers. Name the project PositionsV2, and make sure that the Generate data package option is set to Yes. Add a single entity (PositionsV2) to the project, and select the format to export in.

Note : First time, It will push all data and next time It will be incremental push.

Create a Power automate solution

First we will create a power automate solution and add all the environment variables with the default values.

Once the environment is created then next step is to create a cloud flow.

Step 1 : Set the recurrence as per your requirement.

Step 2 : Define the project name and legal entity as an environment variable.

Step 3 : Create a guid(use an expression – guid())

Step 4 : Get the token

We have to use HTTP Post method and get the token from Dynamics 365 HR. In this case, use the environment variables.

Step 5 : Access the token

Get the access token from the previous step.

Step 6 : Start export data

Use the HTTP post method to export the data

  • Method: POST
  • Url of the request: https://<hostname>/namespaces/<namespace_guid>/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.ExportToPackage
  • Body of the request:
    "definitionGroupId":"Use from the variables",

Step 7 : Wait until the execution status of the data export is Succeeded.

  1. Add an Until loop that repeats until the value of the ExecutionStatus variable is Succeeded.
  2. Add a Delay action that waits five seconds before it polls for the current execution status of the export.

Set the limit count to 15 to wait a maximum of 75 seconds (15 iterations × 5 seconds) for the export to be completed. If your export takes more time, adjust the limit count as appropriate.

Step 8 : Check for success

Check whether the status is succeeded

Step 9 : If the status is YES then get the package, download the file and save to FTP storage.

Step 10 : Get the package URL

Step 11 : Download the file

Step 12: Export the data to FTP and extract the data.

Step 13 : If the status is NO then no action or send email to user with status failed.

Test the flow

To test your power automate, select the Edit button and click on Test. You will see that the steps of the power automate start to run. After 30 to 40 seconds, the power automate should finish running, and your FTP folder should include a new package file that contains the exported positions.

If a failure is reported for any step, select the failed step in the designer, and examine the Inputs and Outputs fields for it.

The following illustration shows what the Power automates Designer looks like when all the steps of the power automate run successfully.

The run the flow manually or make it based on recurrence.

It will download a CSV file to FTP folder.



In this article, We saw how to use Rest API to export data from Dynamics 365 HR. This can be done in many ways but this one was the possibilities. If you like this article, feel free to share it others who might find it helpful. If you have any questions, feel free to get in contact with me.

1 Comment

  1. […] data export scenarios. The following table describes the main decision points that you should…… Continue Reading → Read Complete Post and Comments SBX – Two Col […]

Leave a Reply

Your email address will not be published. Required fields are marked *