Power Automate Fundamentals # 2: Usage of Encode Uri in Power Automate

Introduction:

In Power Automate, to return a uniform resource identifier (URI) encoded version for a string by replacing URL-unsafe characters with escape characters we can use either encode UriComponent or uriComponent functions in expressions.

Step 1:

Login to the required Power Apps environment using URL make.powerapps.com by providing user name and passwordand click on Flowson the left hand side as shown in the below figure.

Figure 1

websym

Step 2:

After Step 1, click on New Flow and then Instant Flow and under option Choose how to trigger the flow select Manually tigger a flow and click on Create button as shown in the below figure.

Figure 2

 

Step 3:

After Step 2, provide name as Encode Uri for the flow and then select an operation with name Initialize variable Action  as shown in the below figure.

Figure 3

Step 4:

After Step 3, Initialize variable is used to hold url that needs to be encoded, so provide the name as Uri and Type as String and Value as https://venkatasubbaraopolisetty.com/and click on New Step as shown in the below figure.

Figure 4

Step 5:

After Step 4, select an Action Compose under Choose an operation as shown in the below figure.

Figure 5

Step 6:

After Step 5, under Inputs click on Expression and type

encodeUriComponent(variables(‘Uri’))

here encodeUriComponent() is the function and variables (‘Uri’) is the variable value which we received from step 4 as shown in the below figure.

Figure 6

Step 7:

After Step 6, Click on Save button and click on Test as shown in the below figure.

Figure 7

Step 8:

After Step 7, Click on Manually and Click on Test  as shown in the below figure.

Figure 8

 

Step 9:

After Step 8, Click on Run Flow and you could see below screen and click on Done as shown in the below figure.

Figure 9

Step 10:

After Step 9, input initialize variable with Uri turned to encoded uri which is encoded version for a string by replacing URL-unsafe characters with escape characters as shown in the below figure.

Figure 10

Step 11:

After Step 10, we can also use another recommended function uriComponent by Microsoft by providing under compose operation under expression to encode

uriComponent(variables(‘Uri’))

which will encode to equivalent encoded version for a string by replacing URL-unsafe characters with escape charactersand save and Test (Repeat Steps 8 and 9)and can see same expected result as shown in the below figure.

Figure 11

Step 12:

After Step 11, one can find both Power Automate functions provided same result as shown in the below figure.

Figure 12

Note:

  1. Make sure to save and run the flow whenever you try expressions.
  2. MS documentation is found at https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#uriComponent
  3. As an example my website is taken into consideration to provide as variable in Step 4, you can provide any other value of your choice.

Conclusion : In this way one can easily generate encoded version for a string by replacing URL-unsafe characters with escape characters.

About the Author :

Mr. Venkata Subbarao Polisetty [C# Corner MVP] currently working as a Lead Software Engineer at EPAM ( https://www.epam.com/).
He was earlier working with  Accenture, Infosys Ltd., Robert Bosch Engineering and Business Solutions Ltd.
He is also currently leading the D 365 Champs User Group from Hyderabad Region contributing to Microsoft as an community contribution.
He is having 11+ years of experience in Asp.Net, C#, Microsoft Dynamics CRM 2016 and Dynamics 365, SQL Server, Microsoft Azure, Power Platform, Power Automate and Power BI,Portals, Unified Service Desk, Infobasic, T24 & Python.
He is a Power Platform Architect and Azure Architect as well certified in Microsoft Dynamics CRM 2015, 2016, Dynamics 365 CE. Also, he is a Microsoft Certified Trainer (MCT).

He can be Contacted at:
Mobile : +91-99491 68967
Email : [email protected], [email protected]

 

Also read Series #1

Series #1