Ethan Millar

1 month ago · 1 min. reading time · visibility ~10 ·

chat Contact the author

thumb_up Relevant message Comment

Make HTTP Requests from CRM using Power-Automate

A few years ago, making an HTTP call from Dynamics CRM Services used to be very complex. The developers had to resort to C# Plugins or Workflows. In this blog, we will learn how we can consume an HTTP API by triggering an event from D365 CE (CRM) with the help of a Power-Automate (Flow). 

The requirement would be – Once a user creates a D365 Account providing values to Latitude and Longitude, a Power-Automate must make a GET request to the Bing Maps API and find the time zone based on the given account Coordinates.

STEPS

  1. We create a new Power-Automate (Flow) that triggers on creation & update of account rows, provided the columns address1_latitude & address1_longitude are not empty. We also add a string variable called timezone_name.
[Bl oe ret is cates

| [onme— ®

2. Next, we add an HTTP action to make a GET request to the Bing Maps API. Here, the URI must be of the format:

https://dev.virtualearth.net/REST/v1/timezone/@{triggerOutputs()?['body/address1_latitude']},@{triggerOutputs()?['body/address1_longitude']}?key=<BingAccountKey>

You can create your own Bing Maps Dev Center key by signing into the Bings portal - https://www.bingmapsportal.com/

Test Accom | rn. san

my Ou Amr sod may ing onde fy Ad od

FEORTE

3. We parse the output of the above action into a JSON schema. The content would be (with the help of an expression) - @{body('HTTP_-_Get_Timezone')['resourceSets'][0]['resources'][0]}. The JSON schema is as follows:

{"type":"object","properties":{"__type":{"type":"string"},"timeZone":{"type":"object","properties":{"genericName":{"type":"string"},"abbreviation":{"type":"string"},"ianaTimeZoneId":{"type":"string"},"windowsTimeZoneId":{"type":"string"},"utcOffset":{"type":"string"},"convertedTime":{"type":"object","properties":{"localTime":{"type":"string"},"utcOffsetWithDst":{"type":"string"},"timeZoneDisplayName":{"type":"string"},"timeZoneDisplayAbbr":{"type":"string"}}}}}}}

4. Finally, we set the value of the timezone_name variable to genericName from the output of the Parse JSON output action. Save these changes in the Power-Automate.

© Acne Ue pa Tine on one 3 on « fae 1 97501 19808 © teen

© rte rt,

Er Bf

UNIT-TESTING

  • We create a new Account with feeding values to the Coordinates (Latitude and Longitude).
Uju13.jpeg
  • We verify that our Power-Automate triggers and finds out the time-zone based on these coordinates as expected.
AQFsF.jpeg

CONCLUSION

Hence, we were successful in getting an API response after making an HTTP GET request in our Power-Automate (Flow), which triggers an event in D365 CE (CRM). Likewise, we can make HTTP PUT, POST, PATCH and DELETE requests as well.

Stay tuned for upcoming blogs!

thumb_up Relevant message Comment
Comments

More articles from Ethan Millar

View blog
4 years ago · 0 min. reading time

Upgrading or Re-Implementation of Dynamics 365 For Operations

While many Microsoft Dynamics AX technical users a ...

5 years ago · 2 min. reading time
5 years ago · 0 min. reading time

Cleansing data with Pig and storing JSON format to HBase with Pig UDF

This post will explain you the way to clean data a ...