Contact Us 1-800-596-4880

Microsoft Dynamics 365 for Operations Connector 2.1 - Mule 4

Anypoint Connector for Microsoft Dynamics 365 for Finance and Operations (Microsoft Dynamics 365 for Operations Connector) enables integration with Microsoft Dynamics 365 for Operations Web API. You can configure this connector using Anypoint Studio. This connector enables connection types for OAuth 2 or OAuth 2 with a username and password.

This connector enables you to perform these operations:

  • Authorize or unauthorize access to a Microsoft Dynamics 365 for Operations server

  • Create a recurring job on Microsoft Dynamics 365 for Operations server

  • Retrieve multiple entries, including retrieval using DataSense Query Language

  • Execute operations

Before You Begin

  • For software requirements and compatibility information, see the Microsoft Dynamics 365 for Operations Connector Release Notes.

  • Familiarity with Microsoft Dynamics 365 for Operations and Anypoint Platform, including Mule runtime engine, Anypoint Studio, elements in a Mule flow, and Global Elements.

  • You need login credentials to test your connection to your target resource.

  • To use this connector with Apache Maven, view the pom.xml file dependency information in Dependency Snippets for this connector in Anypoint Exchange.

  • You need access to a Microsoft Dynamics 365 instance (online or on-premise) managed by Azure Active Directory.

POM File Information

<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-microsoft-dynamics365-for-operations-connector</artifactId>
  <version>x.x.x</version>
  <classifier>mule-plugin</classifier>
</dependency>

Replace x.x.x with the version that corresponds to the connector you are using.

To obtain the most up-to-date pom.xml file information, access the connector in Anypoint Exchange and click Dependency Snippets.

Connect in Anypoint Studio 7

To configure a connector in Anypoint Studio:

  1. Add the connector to your project

  2. Configure the connector

  3. Configure an input source for the connector

Add the Connector in Studio

  1. In Studio, create a Mule project.

  2. In the Mule Palette, click (X) Search in Exchange.

  3. In Add Modules to Project, type "operations" in the search field.

  4. Click Microsoft Dynamics 365 for Operations Connector in Available modules.

  5. Click Add.

  6. Click Finish.

Configure in Studio

Drag the connector to the Studio Canvas.

Create a global element to:

Configure OAuth 2

Field Description

Resource

The OAuth endpoint URL.

Consumer Key

The app ID assigned to your app when you registered it with Azure Active Directory. You can find this in the Azure Portal (portal.azure.com). Click Active Directory, click the directory, choose the app, and click Configure.

Consumer Secret

The secret that you created in the app registration portal for your app. This should not be used in a native app, because client secrets cannot be reliably stored on devices. This is required for web apps and web APIs, which have the ability to store the client secret securely on the server side. You can find this in the Azure Portal (portal.azure.com). A client secret is a numerical value known only to your app and the Azure server, which enables access for your app.

Authorization URL

Tenant-specific OAuth2.0 endpoint in the format: https://login.microsoftonline.com/{tenant}/oauth2/authorize (follow instructions presented in the previous link for specific information on how to obtain the endpoint)

Access token URL

Tenant-specific endpoint for requesting the access token in the format: https://login.microsoftonline.com/{tenant}/oauth2/token (follow instructions presented in the previous link for specific information on how to obtain the endpoint).

Listener config

Name of the HTTP Listener instance created in the Anypoint Studio flow.

Callback path

The URL of your app, to which authentication responses can be sent and received by your app (follow instructions presented in the above link for specific information on how to obtain the endpoint).

Authorize path

The URL that triggers the OAuth mechanism.

External callback URL

Required only if the callback URL is not accessible directly (example: when using proxies) example format: http://localhost:8081/callback

microsoft 365 ops as oauth2

Configure OAuth 2 Username and Password

Field Description

Username

Username used to initialize the session.

Password

Password used to authenticate the user.

Resource

The app ID URI of the web API (secured resource). This must be the root URI, without specifying the version: for example, https://YOUR_ORG.operations.dynamics.com/

Client ID

The ID assigned to your app when you registered it with Azure Active Directory. You can find this in the Azure Portal (portal.azure.com). Click Active Directory, click the directory, choose the app, and click Configure.

Client Secret

The secret that you created in the app registration portal for your app. This should not be used in a native app, because client secrets cannot be reliably stored on devices. This is required for web apps and web APIs, which have the ability to store the client secret securely on the server side. You can find this in the Azure Portal (portal.azure.com). A client secret is a numerical value known only to your app and the Azure server, which enables access for your app.

Token Request Endpoint

The token endpoint that is called to get the access token. Example: https://login.windows.net/TENANT_ID/oauth2/token where TENANT_ID is the Azure Active Directory ID.

microsoft 365 ops as oauth username pass

Use Case: Accept Data and Output into JSON

This use case enables you to work with the features of Microsoft Dynamics 365 for Operations using the Retrieve Multiple operation.

  1. Listener (HTTP) - Accepts data from HTTP requests.

  2. Dynamics AX for Operations - Connects and executes a query to retrieve all the customer entities.

  3. Transform message - Outputs the results of the Retrieve Multiple operation in JSON format.

microsoft 365 ops studio use case

Use a properties file to define these attributes for use in the flow:

  • username="${operations.username}"

  • password="${operations.password}"

  • resource="${operations.resource}"

  • clientId="${operations.client_id}"

  • clientSecret="${operations.client_secret}"

  • tokenRequestEndpoint="${operations.request_endpoint}"

You can paste this XML code into Anypoint Studio to experiment with the flow:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:dynamics365ForOperations="http://www.mulesoft.org/schema/mule/dynamics365ForOperations"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/dynamics365ForOperations
http://www.mulesoft.org/schema/mule/dynamics365ForOperations/current/mule-dynamics365ForOperations.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
		<http:listener-connection
		host="localhost"
		port="8081" />
	</http:listener-config>
	<dynamics365ForOperations:dynamics-365-for-operations-config
		name="Dynamics_365_For_Operations_Dynamics_365_for_operations"
		doc:name="Dynamics 365 For Operations Dynamics 365 for operations">
		<dynamics365ForOperations:oauth2-user-password-connection
			username="USERNAME"
			password="PASSWORD"
			resource="https://muledev.sandbox.operations.dynamics.com"
			clientId="CLIENT_ID"
			clientSecret="CLIENT_SECRET"
			tokenRequestEndpoint="https://login.windows.net/TOKEN/oauth2/token" />
	</dynamics365ForOperations:dynamics-365-for-operations-config>
	<dynamics365ForOperations:dynamics-365-for-operations-config
	name="Dynamics_365_For_Operations_Dynamics_365_for_operations1"
	doc:name="Dynamics 365 For Operations Dynamics 365 for operations">
		<dynamics365ForOperations:oauth2-user-password-connection
		username="${operations.username}"
		password="${operations.password}"
		resource="${operations.resource}"
		clientId="${operations.client_id}"
		clientSecret="${operations.client_secret}"
		tokenRequestEndpoint="${operations.request_endpoint}" />
	</dynamics365ForOperations:dynamics-365-for-operations-config>
	<flow name="dynamics-op-testFlow">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/retrieve" />
		<dynamics365ForOperations:retrieve-multiple doc:name="Retrieve multiple"
		config-ref="Dynamics_365_For_Operations_Dynamics_365_for_operations1">
			<dynamics365ForOperations:data-query-url ><![CDATA[https://muledev.sandbox.operations.dynamics.com/data/Customers]]></dynamics365ForOperations:data-query-url>
		</dynamics365ForOperations:retrieve-multiple>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
</mule>
View on GitHub