Power Automate Functions: EncodeURIComponent / DecodeURIComponent (Make URLs Safe!)

Power Automate Functions EncodeURIComponent DecodeURIComponent


Welcome to another blog post about Power Automate Functions: EncodeURIComponent DecodeURIComponent. EncodeURIComponent is used to protect the URLs by encoding them. And DecodeURIComponent is used to decode the URL by decoding it. Today we're going to see that how can we use both of these functions in power automate. We will write expressions for both of these functions and I will show you step by step that how can we Encode URL and Decode URL using EncodeURIComponent and DecodeURIComponent respectively.

Some characters are used to safe url like mentioned below:

: = %3A

/ = %2F

Space = %20

So, we will use EncodeURIComponent to encode our URL or to protect our URL.

Input:

https://www.shahryarsultan.com/

The output will be as:

https%3A%2F%2Fwww.shahryarsultan.com%2F


EncodedUriComponent will be used for this purpose.

We have to initial variables like:

Initialize a variable here and set its attributes

 

Power Automate Functions EncodeURIComponent DecodeURIComponent

Set its attributes like give a Name to it set its type from the dropdown button and then set the value you want to encode or decode

 

Power Automate Functions EncodeURIComponent DecodeURIComponent

Search compose action from the search bar:

 

Power Automate Functions EncodeURIComponent DecodeURIComponent

First, we initialize the variable and then make an action for output then call the variable in expressions

Expression: encodeUriComponent(variables('Decode or Encode URL'))

 

Power Automate Functions EncodeURIComponent DecodeURIComponent

Here is the output:

Power Automate Functions EncodeURIComponent DecodeURIComponent

To Decode URL, I am taking the output from the compose and then I will use DecodeURIComponent. In this way we can decode the URL as well.

Use the ‘decodeUriComponent’

Power Automate Functions EncodeURIComponent DecodeURIComponent

Expression: DecodeUriComponent(outputs('Compose'))

Output of DecodeURIComponent

Power Automate Functions EncodeURIComponent DecodeURIComponent


0 Comments

Thanks for commenting. Your comment will be live soon after approval.