In rest message getting {"detail":"JSON parse error - Invalid \\escape: line 11 column 31 (char 359)\nPossible cause: trailing comma."}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-15-2022 07:15 AM
Hi,
I am getting {"detail":"JSON parse error - Invalid \\escape: line 11 column 31 (char 359)\nPossible cause: trailing comma."}
error while passing value in rest message.
Workflow script:
var i = new GlideAggregate('sys_user');
var m = '';
var x = mr();
var j = '';
var x = current.variable_pool.select_users_groups.getDisplayValue();
if (x == 'Group') {
j = current.variables.please_enter_the_dl_group_name.u_cn.getDisplayValue();
} else {
j = names();
}
function names() {
var j = [];
var i = new GlideRecord('sys_user');
i.addQuery('sys_id', 'IN', current.variables.username);
i.query();
while (i.next()) {
j.push(i.email.toString());
}
return j;
}
function mr() {
var mrv;
var itemID = current.sys_id;
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(itemID)) {
mrv = ritmGR.variables.path;
// gs.addInfoMessage("a=" + mrv);
}
m = mrv.path_1;
}
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery('short_descriptionSTARTSWITHNeed access to storage' +'^parent=' + current.sys_id);
gr.query();
if (gr.next()) {
var number = gr.number;
}
var instanceURL = gs.getProperty('glide.servlet.uri');
var callbackUrl = instanceURL + 'api/now/table/sc_task/' + gr.sys_id;
try {
var r = new sn_ws.RESTMessageV2('Ansible-NetworkShareAccess', 'NetworkShareAccess');
r.setStringParameterNoEscape('callbackUrl', callbackUrl);
r.setStringParameterNoEscape('ticketNumber',number);
r.setStringParameterNoEscape('sysId', gr.sys_id);
r.setStringParameterNoEscape('sn_sharePaths', m); // here getting error
r.setStringParameterNoEscape('sn_principalType', current.variable_pool.select_users_groups.getDisplayValue());
r.setStringParameterNoEscape('sn_principal', j);
r.setStringParameterNoEscape('sn_permissionType', current.variable_pool.please_select_the_type_of_access.getDisplayValue());
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
Like this I'm submitting value
Thanks,
Sowmya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-15-2022 07:22 AM
Hi, As per your code - I can see 'm' is getting value from this function
function mr() {
var mrv;
var itemID = current.sys_id;
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(itemID)) {
mrv = ritmGR.variables.path;
// gs.addInfoMessage("a=" + mrv);
}
m = mrv.path_1; //What is path_1 and what it represents.
}
Can you check that highlighted line?
Please mark as correct answer/helpful if it helped.
Regards,
Suresh.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-17-2022 04:02 AM
Hi
Thank you for the reply. Yes, I'm passing the sharepath using this function. In share path it contains backslash so I am unable to pass the values getting trailing comma error.
Can you please help me on passing values.
Thanks,
Sowmya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-15-2022 07:30 AM
Hi,
Please use the appropriate forum feature: "Insert/Edit code sample" when pasting script on the forums so that it remains organized and easier to read:
The error you're seeing is because of the double backslash \\ in that last value within your JSON. So to escape that (meaning to keep it), there'd need to be 2 more additional backslashes so that they are escaped properly, meaning:
"key":"value" such as "key":"[\\\\eaclab2\blahblah]"
So when it's getting escaped currently, I'm guessing it's causing a problem with the result.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-15-2022 07:37 AM
Can you please help me where i need edit the code
Thanks,
Sowmya