double quote ( " ) will be converted in &quot when sending REST message

Eckhard
Tera Contributor

Dear community,

I am building a REST message which includes a random password, which gets created with OOTB class "PwdCryptoSecureAutoGenPassword".
I build the REST message with:
var restMessage = new sn_ws.RESTMessageV2('[RESTMessage]', '[HTTP-Method]');
var password = new PwdCryptoSecureAutoGenPassword().process();
restMessage.setStringParameter('password', password);

...

 

In general this works perfct, but when the generated password contains a " then the password that gets received on the other system via REST call looks like e.g.:

a4""!AcM instead of
a4""!AcM

I read that JSON is based on UTF-8, so no escaping is needed (one of the differences to XML), but do you have an idea, why the other system receives the password in such a way?
Many thanks
Best regards
Eckhard

 

 

 

1 ACCEPTED SOLUTION

Hi @Eckhard 

 

 

You can use "setStringParameterNoEscape()" instead of "setStringParameter()" in your script.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0821441

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

3 REPLIES 3

Vishal Birajdar
Giga Sage

Hi @Eckhard 

 

Below link might help you...!!

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0692465

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Eckhard
Tera Contributor

Hi Vishal,
many thanks for your feedback.
The thing is ... I do not use the "Test" functionality in the REST messages.
I send the REST message via script as I described, so I am not sure if your solution helps me with my script.
I believe I would have to mention this in my script to set the variables with a kind of escaping.
Do you have an idea?
many thanks

Best regards

Eckhard

Hi @Eckhard 

 

 

You can use "setStringParameterNoEscape()" instead of "setStringParameter()" in your script.

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0821441

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates