How to change to JSON stringify : Cannot decode: java.io.StringReader

nomadie
Kilo Expert

I have this Business Rule for Rest Message Patch method that I need to fix because I keep having this error.

HTTP Status : {"error":{"detail":"Cannot decode: java.io.StringReader@70dd85","message":"Exception while reading request"},"status":"failure"}

(function executeRule(current, previous /*null when async*/) {

	// Condition is : current.correlation_idISNOTEMPTY
	gs.log('In Business Rule New Run', 'check');
	try {
		var comment = current.comments.getJournalEntry(1);
		gs.log('Comment : ' + comment, 'check');
		gs.log('Cor ID : ' + current.correlation_id, 'check');
		var r = new sn_ws.RESTMessageV2('Ebond', 'Patch Ebond');
		r.setStringParameterNoEscape('sys_id', current.correlation_id);
		r.setStringParameterNoEscape('comments',comment);
				
		var response = r.execute();
		var responseBody = response.getBody();
		var httpStatus = response.getStatusCode();
		gs.log('HTTP Status : ' + responseBody,'check');
		
	}
	
	catch(ex) {
		var message = ex.message;
	}
	
	gs.log("End Business Rule", 'check');
	
})(current, previous);
5 REPLIES 5

srikanth82
ServiceNow Employee
ServiceNow Employee

You are getting this error because of the input you are giving as a payload. And the restend point was not able to encode the format you are sending with.