Dynamics CRM: Integrate to Other Source System Easier using Power Automate

I have a lot of experience integrating Dynamics CRM with the other source systems that required a lot of code to be built in the plugin. We need to connect to Web API > parse the response > mapping the response > then verify the result. If you ask me to do it in the code, sure it will be a complex task to do and we need multiple lines of code to handle this. But nowadays with Power Automate, we can simplify the effort with basically, just 2 types of action in Power Automate: HTTP and Parse JSON and it doesn’t cost a lot of time to do it anymore. 

For the scenario that we want to build. I will not make my own Web API (for simplicity). Instead, I will call Twitter API (sure we will not using the existing connector to show how to handle these things). Because Twitter API already implements OAuth for securing their API. You need to register first to get api_key and api_secret (this part I will not explain any further).

Flow Creation

I create an automated cloud flow and the first step is to get the access_token using HTTP action. This step basically, is for doing authorization. We provide api_key and api_secret to exchange with an access_token. We need to call HTTP POST in this https://api.twitter.com/oauth2/token?grant_type=client_credentials URL:

Dynamics CRM
HTTP POST to get access_token from Twitter Server

In return, the server will give us access_token. This access_token will be provided in our HTTP Header so the Resource Server understands that we have the right to access the API that we want. So for this step, we need to parse the return response using Parse JSON action:

Dynamics CRM
Parse the response based on the Twitter JSON sample to get the Schema

For generating the Schema, we can input the Twitter JSON sample. After we press the Done button, Power Automate will generate the Schema for us to be used in the next step.

Dynamics CRM
Insert a sample JSON Payload to generating the schema

With this step, we actually can invoke the Twitter API that we want. For this sample, I will call get User by Username which we will use HTTP GET in this https://api.twitter.com/2/users/by/username/:username URL. So the next step is to create HTTP action again:

Dynamics CRM
Get Username and supply the access_token

If the request valid, we will get a JSON response. So once again we need to make JSON Parse action:

Dynamics CRM
JSON parse the result for get username

Same with the previous step for JSON Parse action. We can submit the sample to get the data that we need:

Twitter Username JSON sample

With all those steps. We can use the response of the API. For this scenario, I will just make a record in CRM.

Create CRM Record

Demonstration

Here is the demonstration where I called the flow, and just refresh the model-driven apps to check whether the record was created or not.

Dynamics CRM
Call the flow and verify

Summary

HTTP and Parse JSON action will be my favorite action in Power Automate. We can simplify a lot of processes using this combination!

For more great content, check out the Resource Centre

About the Author:

My name is Temmy Wahyu Raharjo. I am a passionate programmer who loves the idea of Clean Code. A grasshoper of a Test Driven Development. .Net programmer, Angular newbie, Microsoft Dynamic CRM Consultant.

Thanks for stopping by! Hopefully you can learn something here and I do like to chit chat with you if you have question!

Reference:

Raharjo, T. (2021). Dynamics CRM: Integrate to Other Source System Easier using Power Automate. Available at: https://temmyraharjo.wordpress.com/2021/02/20/integrate-with-other-source-system-seamlessly-with-power-automate/ [Accessed: 3rd March 2021].

Share this on...

Rate this Post:

Share: