Illegal access to private script include JSONParser

Geeky
Kilo Guru

Hi,

I am getting error message

{"error":{"message":"Illegal access to private script include JSONParser in scope rhino.global being called from scope sn_customerservice","detail":"Illegal access to private script include JSONParser in scope rhino.global being called from scope sn_customerservice"},"status":"failure"}
I have a Scripted Rest API as below;
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {


	body = global.JSON.stringify(request.body.data);
	return new createCase().create(body);
	
})(request, response);

And in script include I have below code;

var createCase = Class.create();
createCase.prototype = {
    initialize: function() {
    },

	create: function(values) {
		
		gs.info('function called');
       var parser = new global.JSONParser();
	var parsed = parser.parse(values);
		
// 		var json = new global.JSON();
// var parsed = new JSON().decode(values.json_output.toString());
		
        var sd = parsed.short_description;

    }
       return sd;
    },
	
    type: 'createCase'
};
1 ACCEPTED SOLUTION

Omkar Mone
Mega Sage

Also instead of using JSONParser, you can straightaway use JSON.parse(values) and JSON.stringify() methods which does the same job also which are JS methods so wont throw any error of this kind.

 

Hope this helps.

 

Regards

Omkar Mone

View solution in original post

7 REPLIES 7

Hi

You can put the code in the try{}catch(e){} block and get the errors.

 

Regards

Omkar Mone

How to display error message to user? e.messgae?

Hi 

You can do it something like this - 

try{}catch(err){gs.log('Got Error: ' + err);}

 

Regards

Omkar Mone