We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to escape special characters

surya123
Mega Guru

Hi All,

I am sending the json to 3rd party system. So using the BR i was forming it this way -

 

var r = new sn_ws.RESTMessageV2('Creation', 'Default PUT');

r.setStringParameterNoEscape('adhocID', current.number);
r.setStringParameterNoEscape('fieldid', current.field_id);
r.setStringParameterNoEscape('state', stateVal);
r.setStringParameterNoEscape('worknote', current.work_notes));
r.setStringParameterNoEscape('group', current.assignment_group.getDisplayValue());
r.setStringParameterNoEscape('closed', current.closed_at);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();

 

I get an error message as the "Record was misformed" when the worknote is typed as-

 

ASU, Test
testasu
CN=tyty\, fgt,OU=CGS Users,DC=tester,DC=cvs
Wednesday, December 27, 2017 12:19:12 PM

How can i escape the speacial characters or any issue with this and get it working?

Thanks

Surya

18 REPLIES 18

Mike Patel
Tera Sage

try below

 

var r = new sn_ws.RESTMessageV2('Creation', 'Default PUT');

r.setStringParameter('adhocID', current.number);
r.setStringParameter('fieldid', current.field_id);
r.setStringParameter('state', stateVal);
r.setStringParameter('worknote', current.work_notes);
r.setStringParameter('group', current.assignment_group.getDisplayValue());
r.setStringParameter('closed', current.closed_at);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();

What has changed in this script?

setStringParameterNoEscape to setStringParameter

Hi Mike

Do we have some way where we can escape all special characters or anything that misforms the json ?

I see that when " is used it again shows 400. For some other characters it might still show issue. Is there a way we can handle this?