How to add Query Parameters with space in SerivceNow Rest APi?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 01:02 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2023 10:23 PM
just encode the parameters then and not complete URL
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2023 12:32 AM