cancel
Showing results for 
Search instead for 
Did you mean: 

How to Encode and Decode URL's in Nintex Workflow (all versions)

aaron_labiosa
Nintex Newbie
18 6 4,135

The other day I overheard someone needing to encode/decode a URL string inside of a Nintex Workflow (and again at the Nintex 2017 InspireX during a presentation on Azure Functions). Presently this is a non-trivial task (more information here), so I decided to simplify the process a bit by creating a set of REST web service endpoints that would handle the encoding/decoding process.

These web services can easily be called from the Nintex Workflow Web Request actions in On premises products as well as O365.

To use these web service endpoints, configure a 'Web Request' action to POST application/json content to these endpoints:

Encode: http://swunaapi.azurewebsites.net/api/Url/Encode 

Decode: http://swunaapi.azurewebsites.net/api/Url/Decode 

To use the endpoints POST the following JSON:

{"value" : "Url To Encode/Decode"}
6 Comments
workingjonathan
Nintex Newbie

Very cool!

rhia
Nintex Newbie

For those of us who know this is impressive but don't really know what it means, can you give an example of when one might want to use this? Or for what reason?

aaron_labiosa
Nintex Newbie

Hi Rhia,

Thanks for the feedback! I suppose I should have called a bit more attention to my mention of the UserVoice entry that prompted me to build this initially: https://nintex.uservoice.com/forums/229405-1-nintex-workflow-for-sharepoint/suggestions/10284486-add...

Here is the contents so folks do not have to click over:

Add "URL encode" and "URL decode" Action

We meet situations quite often when need to create customized URL which is saved and used later for redirecting within or outside SP. For this purpose we need to encode input text to valid URL and save it.

Opposite situation is for reading existing URL (decode) and parsing several elements for additional usage.

While URL encode / decode is quite simple for programmer (few lines of code) but very difficult (or impossible) to perform with current tools such as "Build String" for WF designer.

Existing/known workaround:
http://www.vadimtabakman.com/nintex-workflow-url-encoding-user-defined-action.aspx
Multiple embedded "fn-Replace" functions are not a good solution because there can be many of them and WF designer can forget some and the result is not good. Maintenance of such a UDA is also very difficult.

Suggested solution:
http://meyerweb.com/eric/tools/dencoder/
Both functions are quite easy to perform in Visual Studio. Included link shows how it should work.

Thank you!
Michal

andrew_x_childr
Nintex Newbie

I have had a use case where I needed to take user input to create a new list/library in SharePoint, so had to "encode" their input to deal with all characters that can't be used in URLs.  Instead of properly encoding the URL, I used a regular expression action in a workflow to just remove all the illegal characters.  It can be a bit ugly, but it's another workaround for some situations.

Regular expression pattern:

'|\.|\/|-|\s|!|\*|\(|\)|;|Smiley Indifferent@|&|,|\?|%|#|\[|\]

(The | means “or” in regex, and \ is the escape character.)

Interpretation:

“If you find any of these weird characters in the Title, replace them with nothing, then save the result in the variable CleanNameForURL”.

aaron_labiosa
Nintex Newbie

I think you were one of the folks that inspired the creation of this haha!

radityo_ardi
Nintex Newbie

Just wondering, when this will be integrated inside Nintex for Office 365?

Is there any assurance that the API above will stay forever?