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).
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:
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:
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.
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:
If the request valid, we will get a JSON response. So once again we need to make JSON Parse action:
Same with the previous step for JSON Parse action. We can submit the sample to get the data that we need:
With all those steps. We can use the response of the API. For this scenario, I will just make a record in CRM.
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.
HTTP and Parse JSON action will be my favorite action in Power Automate. We can simplify a lot of processes using this combination!
What you think?