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

Still same issue. When i did a addinfomessage it showed a lot of \\\\\\\\\\\\\\\\\\\\\.

Can you guide me as to what i can try ?

try changing below

notes +=(gr.sys_created_on + ' - ' + gr.sys_created_by + ' ' + gr.element + '- ' + gr.value + '\n');

Hi

I figured out that new lines is also causing the issue. I added to replace newlines. But then in the 3rd party system, it goes without any linebreaks and all get added as 1 line. Can I send them as new lines?

can you log json and see what exactly is being sent. do like gs.log(json.encode(notes));