Contact Free trial Login

Microsoft Dynamics 365 for Operations Connector 2.0 - Mule 4

Support Category: Select

Anypoint Connector for Microsoft Dynamics 365 for Operations enables integration with Microsoft Dynamics 365 for Operations Web API. You can configure this connector using the Flow Designer feature of Design Center or 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

Prerequisites

  • 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>RELEASE</version>
  <classifier>mule-plugin</classifier>
</dependency>

Mule converts RELEASE to the latest version. To specify a version, view Microsoft Dynamics 365 for Finance and Operations Connector in Anypoint Exchange and click Dependency Snippets.

Connect in Design Center

  1. Click a trigger, such as HTTP Listener or Scheduler and configure the trigger.

    The Microsoft Dynamics 365 for Operations Connector does not provide a trigger operation.

  2. Select the plus sign (+).

  3. In Select a component, search for "op", and click Microsoft Dynamics 365 for Operations Connector.

  4. Click an operation:

    Operation Description

    Execute Operation

    Execute a request using a URL.

    Import Data Recurring Job

    Submit data to recurring data jobs.

    Retrieve Multiple

    Retrieve multiple entities by URL.

    Retrieve Multiple By Query

    Retrieve multiple entities by DSQL query.

    Unauthorize

    Deletes all access token information for a resource owner ID to prevent operation execution until re-authorized.

  5. Select Click here to set it up.

  6. Specify the connection type as OAuth 2 or OAuth Username Password:

    microsoft 365 ops create global element
  7. Provide all other required values.

  8. If using the Retrieve Multiple operation, configure the Data Query URL field:

    microsoft 365 ops retrieve multiple

    The Data Query URL field is in ODATA format.

Configure OAuth 2

These fields require values in Flow Designer for configuring the OAuth 2 connection type:

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 app 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 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). To find the Authorization URL and the Access token URL, browse to the Microsoft Azure portal, App registrations section, and select the Endpoints menu.

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 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 dc oauth2
If using the Retrieve Multiple operation, configure the Data Query URL field, which is in ODATA format.

Configure OAuth 2 Username Password

These fields require values in Flow Designer when configuring OAuth 2 with a 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 dc oauth username pass
If using the Retrieve Multiple operation, configure the Data Query URL field, which is in ODATA format.

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 Using Exchange

  1. In Studio, create a Mule project.

  2. Click the Exchange (X) icon in the upper left of the Studio task bar.

  3. In Exchange, click Login and supply your Anypoint Platform username and password.

  4. In Exchange, search for "operations".

  5. Select Microsoft Dynamics 365 for Operations Connector and click Add to project.

  6. Follow the prompts to install 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 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>