The CreatorCon Call for Content is officially open! Get started here.

How to add Query Parameters with space in SerivceNow Rest APi?

User477307
Tera Contributor

Hi there,

 

I'm trying to connect to a third party URL
where the query parameters are as follows:
@Param1 = All systems;
@param2 = action 3;

Ideally the url in POSTMAN is formed as
https://www.demoendpoint.com/welcome?@param1=All%20systems&@param2=action%203

But ServiceNow Script which I'm using below:
var demotest= new sn_ws.RESTMessageV2('demo', 'DemoAPI');
demotest.setQueryParameter('@param1', 'All systems');
demotest.setQueryParameter('@param2', 'action 3');
demotest.execute();

I'm getting an error saying invalid URI: https://www.demoendpoint.com/welcome?@param1=All+systems&@param2=action+3

You can see in the above URL space is replaced with + rather than %20

 

Can some please help?

 

Thanks,

Pradnyesh.

 

6 REPLIES 6

@User477307 

just encode the parameters then and not complete URL

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

 

Will you be able to help or recommend anyone who could give a work around?