REST Message fails on special characters in URI

swisstech08
Mega Contributor

Hi,

In a rest message uri I have to pass in a variable value that contains special characters:

https://${url}/${site}/groups?filter=name:eq:${adGroup}

Variable Substitution:

url = test.name.com

site = mysite

adGroup = My/ADGroup - Title

When testing the REST request it fails with an error message indicating an invalid uri.

A REST function URI or function variable may use special characters, such as pipe (|) characters.

When using these characters in a REST message, use URL encoding to escape these characters. For example, to use a parameter value of user|title, enter user%7Ctitle. Entering special characters directly may cause the REST message to fail and display the response Invalid uri <URI>: Invalid query.

However, a user is entering the "adGroup" value via a catalog item input and then gets passed via Client Script to the workfklow, meaning I don't handle the input.

How can I get around this issue? Do I have to parse the "adGroup" string for special characters and replace them with url encoding as mentioned above?

 

Sincerely,

Roland

1 REPLY 1

swisstech08
Mega Contributor

I found the solution.

When the user enters a comma separated string with special characters I do the following in the Client script:

    var formatted = "";
    var arrGroup = newValue.split(',');
            for (var group in arrGroup) {
                formatted += encodeURI(arrGroup[group]) + ",";
            }

            g_form.setValue('adGroups', formatted);

 

Sincerely,

Roland