Connecting MuleSoft and Dynamics365 CRM

Zoran Đukić
Another Integration Blog
4 min readOct 10, 2023

Just a quick note. This is the first installment of MuleSoft-Dynamics articles so stay tuned. :)

Dynamics365 is a powerful and widely-used Customer Relationship Management (CRM) platform. However, establishing a connection to Dynamics365 can be a daunting task, particularly if you’re not well-versed in the intricacies of Microsoft Azure. In this article, we’ll walk you through the steps required to connect MuleSoft with Dynamics365 CRM, making the integration process more accessible and less intimidating.

Step 1: Create a Microsoft Developers Account

Before you begin the integration process, you’ll need a Microsoft Developers account. You can create one by visiting https://developer.microsoft.com/en-us/microsoft-365/dev-program. This account will provide you with the necessary access to Azure and other Microsoft services. When you are done with registration navigate to Azure and go to “App registrations.”

Step 2: Azure App Registration

Click on “New registration” to create a new application registration.

Register your app and take note of the essential details: Client ID, Tenant ID, Client Secret, and Endpoint.

For your MuleSoft integration, you’ll need to generate a Client Secret and specify the scope. The scope is typically your CRM URL appended with /.default.
Note: In some cases, a double forward slash will be needed instead of a single forward slash before the .default. This is usually the case when the base URL of the resource being scoped ends with a trailing forward slash. More information about this special consideration can be found here.

App registrations

Step 3: New registration

New app registration

Step 4: Register your app

Register an application

Step 5: Specify the Client ID, Tenant ID, Client Secret, Endpoint, and Scope.

Client ID + Tenant ID
Generate Client Secret
Specify Scopes

Step 6: Setting Permissions

In the Azure portal, it’s crucial to configure permissions correctly for your application. Refer to the following screenshot for guidance in setting the permissions:

Set permissions (click to enlarge)

Step 7: Enter the values in the MuleSoft connector.

Enter the appropriate values for the OAuth Client Credentials within the Global Elements Properties configuration for the MuleSoft Dynamics 365 CRM connector. This setup will ensure that your MuleSoft application can access Dynamics365 CRM seamlessly.

Screenshot of Dynamics CRM connector

With these steps, your MuleSoft integration with Dynamics365 CRM is complete. You’ve now established a connection that allows data to flow between the two systems, enabling you to streamline your business processes.

Bonus Step: Now if you plan on developing a MuleSoft API, you are going to need a connection between Postman and Dynamics. Using Postman you can access the data faster.

You will need to configure all of the same details as you would need for the MuleSoft Connector (your Dynamics URL, Client ID, Client Secret, Tenant ID, Scope).

In addition, you will need the callback URL which was originally specified when you created the connection in Azure. Be sure to use the very same callback URL, or you won’t be able to connect to your account via Postman.

Also, you will need to enable API calls from the outside. Back inside the Azure portal, be sure that the following fields have values of true (lines 6 and 45):

Go to Postman and open a new HTTP GET request.

Creating a new HTTP GET request in Postman

URL: https://yourorg.crm4.dynamics.com/api/data/v9.2 (modify this URL as appropriate for your organization)

Type: OAuth 2.0

Add authorization data to: Request Headers

Token: D365 Token

Header Prefix: Bearer

Grant Type: Implicit

Callback URL: Check the value in your setup

Auth URL: https://login.microsoftonline.com/common/oauth2/authorize?resource=https://yourorg.crm4.dynamics.com/

Scope: https://yourorg.crm4.dynamics.com/.default

Client Authentication: Send as Basic Auth headers

Configuring Postman for OAuth 2.0 (click to enlarge)

After you have entered all the data, click the Get New Access Token button. You will be asked to enter your account credentials.

Now, you are ready to make your first request.

Add your token and send an HTTP GET request to https://yourorg.crm4.dynamics.com/api/data/v9.2/accounts to see the accounts.

Thank you for your time. :)

--

--