Legacy Dev Forum Posts

 View Only

Sign Up

Replace a space with %20 in a variable for running a data action

  • 1.  Replace a space with %20 in a variable for running a data action

    Posted 06-05-2025 18:42

    TobiasJunghans | 2021-03-23 11:06:53 UTC | #1

    Hi is there a way to transform a space in a variable (e.g. companyName: "company name") into a "%20" (e.g. companyName: "company%20name")? I want to use a data action "get external organization by name" in an agent script but if the variable (companyName) has a space (" ") in it then I get the following error: (Failed due to malformed requestUrlTemplate. Illegal character in query at index 70: https://api.mypurecloud.de/api/v2/externalcontacts/organizations?q=Company Name) if I run this data action. Data Action test fails as well but in Developer Tools the space is changed into "%20". How can I change the space into %20? Or is it possible to manipulate the input variable in data action input contract that data action doesn't fail? I'm looking forward to get a hint how to solve my issue. Thanks, Tobias


    Jason_Mathison | 2021-03-24 01:10:10 UTC | #2

    Hi Tobias,

    I actually opened up an internal ticket about this issue the other day, sorry that we haven't got a fix out for this yet.

    Here is a quick and dirty fix that seems to work:

    https://foo.com/$input.MyInputVariableName.replace(" ", "%20")

    This uses the Java string library to replace the spaces in the MyInputVariableName input variable with '%20's.

    --Jason


    system | 2021-04-24 01:10:12 UTC | #3

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 10365