Rest Message Endpoint url contain spaces causing issues

Ayad
Kilo Contributor

Hello All 

i'm having issue with outbound Rest Message, i'm trying to pull job status from BladeLogic automation System, but ServiceNow doesn't like space on the endpoint url, on postman works just fine. url without spaces works fine, placing "%20" in the spaces also works fine, on bladelogic i cannot rename the folders that contain the jobs, that will impact the hundreds of jobs, so is there a way to get it to work?

when i add %20 in these spaces, everything works fine, but i still have a problem, the part of the url that contain spaces its the jobs status, and its variable, i get from Post Message, so each time the Post message run, there will be different job number. 

 

the jobs number will like something like this 

 

/id/SystemObject/Job/NSH Script Job/13fa9536-1385-4daf-a9a2-3b912077a38b/Statuses/Schedule977889

 

the endpoint url 

https://Server:9843/id/SystemObject/Job/NSH Script Job/13fa9536-1385-4daf-a9a2-3b912077a38b/Statuses/Schedule977889

 

to get it to work, the url need to be like this 

https://server:9843/id/SystemObject/Job/NSH%20Script%20Job/fd3438ed-ec8c-421a-89e2-f0410d350fa7/Statuses/Schedule977820/

 

 

and here is the parsing script, works just fine 

var data = JSON.parse(responseBody);   
pm.environment.set("StatusUri", data.OperationResultResponse.OperationResult.value);

so is there is a way to get around it?

how can make it work, either way make Snow works with spaces, or make the Variable contain %20 in the spaces.

any help will be really appreciated 

Thank you 

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

You can use replace function to replace all space in your variable with %20.

 

your_var = your_var.replace(/ /g,"%20");


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

2 REPLIES 2

SanjivMeher
Kilo Patron
Kilo Patron

You can use replace function to replace all space in your variable with %20.

 

your_var = your_var.replace(/ /g,"%20");


Please mark this response as correct or helpful if it assisted you with your question.

Ayad
Kilo Contributor

This is Awesome, its worked 🙂

 

Thank you for your help.