Integrating Dynamic 365 CRM with Third party API via custom connector using Power Automate – Part1
This article is the first part of the integrating Dynamic 365 CRM with Third party API via custom connector using Power Automate discussion series which focuses on giving you a comprehensive description about Creating Custom Connector for Third Party API using Power Automate.
As I need a Third-Party API to access, a bit of google Fu led me to find out this free APILayer, which is really handy to request the exchange rate against a specific currency by setting the base parameter in the request.
Working principle of the solution is:
Our primary goal is to capture live Exchange Rate from third party API and update the currencies records in the Dynamic CE on a daily basis. I have divided this real time use case in to two parts:
1. Creating Custom Connector to retrieve live Exchange Rates using Power Automate
2. Creating recurring flow to retrieve live Exchange Rates for provided currencies and send it for an approval. The approved exchange Rates are updated in Dynamic 365 CRM on confirmation from Business users.
Power platform is enabled developer to create custom connector in five easy steps.
Let’s Start!!
Step #1: Update General Details
General tab, do the following:
Step #2: Specify Authentication Type:
There are several options available for authentication in custom connectors. The Currency Exchange Rate APIs use API Key authentication.
2. Under API Key, update a parameter label, name and location details.
Step#3: Create the connector definition
Custom connectors can have one or more actions. In this article on currency exchange rate connector will only have one action.
1. On the definition tab, select New action.
2. In General section, Add a summary, description and Operation ID for this action. The summary and description will be show in Power Automate to identify the action whereas Operation ID will be used in Power Apps. Operation ID must be a text string with no space.
3. In Request section display inform based on the HTTP request for the action. Select Import fromsample.
4. Specify the information necessary to connect to the API. The Verb list shows a standard set of API request types (GET, POST, DELETE, PUT, PATCH, HEAD, OPTIONS). In our case, selected the GET method and specify the request URL (https://api.apilayer.com/currency_data/live?source=source¤cies=currencies) And then select Import.
When we import the sample URL its query parameters appear in the Request section. We must setup each of the parameters.
Edit the request parameters
In our case, query parameters “source” and “currencies” are required fields. So, we need to change the setting by providing a description and set Is required? field to Yes.
Edit Source Parameter:
Edit Currencies parameter:
5. The Response area displays information based on the HTTP response for the actions. Select Add default response.
6. Just input a sample of the response JSON into the body section and click Import.
Note: The JSON response can be obtained by copying and pasting our sample URL into the web browser.
7. The Validation section display any issues that are detected in API definition. The validation status will be displayed in the upper-right corner of wizard.
Step#4: Code (Preview)
This step is optional. So, I have ignored this step and going to Step 5: Test.
Step#5: Test
Before testing our custom connector, we need to Create connector. Click on Create connector button in the top.
Now custom connector is ready to test. Click on the New connection button.
To Authenticate the custom connector, a new Tab is opened to enter the API key. This API key is obtained from the APILayer web site. After entering the API key, click the create connection button.
Return to the Test tab and click the refresh icon button in the upper-right corner of wizard.
Choose the newly create connector in the selected connection field. Then enter a value for the source and currencies fields. Finally, select Test operation button to our custom connector.
The connector calls the API, and we can review the response, which includes the exchange rate for provided currencies (INR, AUD, EUR).
Our custom connector is ready to fly now. In Part2, I will illustrate how to integrate this custom connector with Dynamic 365 CRM using Power Automate. Stay tuned!