- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 05:06 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 05:30 AM - edited 10-10-2023 05:33 AM
Hi @Eckhard
You can use "setStringParameterNoEscape()" instead of "setStringParameter()" in your script.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0821441
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 05:12 AM
Hi @Eckhard
Below link might help you...!!
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0692465
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 05:26 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 05:30 AM - edited 10-10-2023 05:33 AM
Hi @Eckhard
You can use "setStringParameterNoEscape()" instead of "setStringParameter()" in your script.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0821441
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates