Skip to main content

How Do I Retrieve Information from Dynamics 365 Finance and Operations via OData Request? - Knowledgebase / Lasernet FO Connector / Lasernet FO Connector FAQs - Formpipe Support Portal

How Do I Retrieve Information from Dynamics 365 Finance and Operations via OData Request?

Authors list

This article provides a guide on how you can retrieve data from Dynamics 365 Finance and Operations via an OData request from the FO API. In this example, we will request the Vendor list from All companies.

Create an API registration

The first step is to create an APP registration in your Azure environment. This must be done in the same Azure Tenant as your FO virtual host. Follow these steps:

1. Log into your Azure portal and open the Microsoft Entra ID.

2. Select App registrations from the left menu and then New registration from the top menu.

3. Give the app a name and in the supported account types, select an appropriate type and then Register in the bottom of the screen.

4. Within API permissions select Add a permission from the top and then choose Dynamics ERP.

5. Select Delegated permissions, add all three options. then click Add permissions.

6. Select Certificates & secrets from the left menu and then New client secret.

7. Type in a Description, select Never and then click Add.

8. Copy the code and add it to a text editor such as Notepad. We need the code later as you cannot read it again when you close the form.

9. Select Overview from the left menu and copy Application (Client) ID and Directory (tenant) ID into your Notepad with the Client secret.


10. Log into your FO environment with admin rights and select System administration > Setup  > Microsoft Entra ID applications.

11. Select +New from the top menu and copy the Client ID from your Notepad. Give it a name and add a User that the App should run as. 

Think about what permissions that user has.


Build the connection

Now we will build the connection to the App registration in your Lasernet setup. First, we need to get a Token. Follow these steps:

1. Open your Lasernet configuration and select Modifiers, add an HTTP modifier and give it a name.

2. Select Setup and for Direction choose Output and for Verb select POST

3. Add a Host and a Remote path. The remote path should contain your Directory (tenant) ID, so copy that from your Notepad.

The following image illustrates how it works now, but Microsoft will likely change this in the future.


4. Select the Parameters tab and add these four parameters:

client_id: Your App registrations ID (Copy from your Notepad).

client_secret: Your Client secret ID (Copy from your Notepad).

grant_type: client_credentials.

resource: Your URL to Dynamics 365 Finance and Operations.

5. Select the Headers tab and add this:

Content-Type: application/x-www-form-urlencoded

6. Select Ok to close the form and open the HTTP modifier again and select Run from the menu bar.

Hopefully, you will get a positive response. In the Log window, scroll all the way down to the last line and right-click the line and select Preview.

Check that you get a Token. If you do not get a Token, you need to double-check IDs.

7. Close the form and the HTTP modifier.

8. Add a new HTTP modifier and give it a name.

9. Select Setup and for Direction choose Output and for Verb select GET.

10. Add a Host and a Remote path. The remote path should contain ) }}?cross-company=true if you wish to get data across all companies.

The following image illustrates how it works now, but Microsoft will likely change this in the future.



Host: Your Dynamics 365 Finance and Operations URL.

Remote path: /data/"Entityname"?cross-company=true.

11. Select the Headers tab and add the following:

Authorization: Bearer #BearerToken# (this JobInfo will be created from a script that we are adding later).

12. Select Ok to close the form.

13. Select Modules from the left menu.

14. Add a Scheduler module and give it a name.

15. Select Exit Modifiers and add the following modifiers in the same order:

16. After these modifiers are added, select Add again, click Script and then Edit.

17. Add the following script (the script is extracting the access token from the response):


function extractToken() { //Add the response into a variable var response = job.getJobInfo("OAuthResponse"); //Parse the response variable as JSON var json = JSON.parse(response); if (json !== '' && json !== '{}' && json.access_token !== '') { job.setJobInfo("BearerToken", json.access_token, true); } else { job.setJobInfo("BearerToken", "", true); } } extractToken();



18. Save, close the script and click Ok to close the Modifier form.

19. Move the script modifier, so it is placed in between the two other modifiers.

20. Select Setup, add a time when the scheduler should execute and then close the scheduler form when done.

21. Add a file out module or another output module where you want your JSON file. Add that destination to your scheduler and update the Lasernet service and then you are ready to go.



Here is a sample of the output:


Helpful Unhelpful

3 of 4 people found this page helpful

Add a comment

Please log in or register to submit a comment.

Need a password reminder?

Share