We are delighted to share our new EIC Delivery Methodology for efficiently managing Saviynt Implementations and delivering quick time to value. CLICK HERE.

REST service-now: Escaping special characters

shivmano
Regular Contributor III
Regular Contributor III

Hi Team,

I am trying to escape alphanumeric characters along with special characters like [, ], (, ), ,(comma), '(single quotes), ", \ and space while creating ticket in service-now. 

I am using the below expression but it does not seem to work and is throwing an exception. Please can someone advise if anything is missing here 

replaceAll('[^a-zA-Z0-9_\\-\\[\\]/(),\'"\\s]*', '') 

Thank you

3 REPLIES 3

pruthvi_t
Saviynt Employee
Saviynt Employee

Hi @shivmano ,

Greetings.

Please take a look at below knowledge base article on handling special characters in REST jsons.

https://forums.saviynt.com/t5/saviynt-knowledge-base/json-handling-escape-characters-in-rest-connect...

Thanks,


Regards,
Pruthvi

shivmano
Regular Contributor III
Regular Contributor III

@pruthvi_t thank you for the response. This article tells about escaping the special characters. But, I would like to retain certain special characters as mentioned in my post and escape the rest. What would be the best way to do that? 

You can use standard ReplaceAll Function


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.