Skip to Content
avatar image
Former Member

$.request.parameters.get('key') does not accept '+' in string

Hi,

I try to call an XSJS Service with a mobile number as an parameter.

******.xsjs?cmd=read&key='(+49) 123 456 7890'

In the job the + sign is removed.

Here ist my code.

var aCmd = $.request.parameters.get('cmd');
switch (aCmd) {
    case "read":
        var key2 = $.request.parameters.get('key');
        read(key2);
        break;
    default:
        $.response.status = $.net.http.BAD_REQUEST;
        $.response.setBody('Invalid Command');
}

Any hints, what to do ?

Thanks Klaus

xsjs-debugging.jpg (91.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jun 13, 2017 at 09:46 AM

    You have to encode the value you are passing to the parameter. If your client calling the service is a JS client, you can use the function encodeURIComponent. On server side in the xsjs coding, you can use function decodeURIComponent to get the original value.

    Regards,
    Florian

    Add comment
    10|10000 characters needed characters exceeded