Trying to call a REST object from a script got: Cannot find default value for object.

Nicol_
Giga Contributor

Hi,
I'm trying to call a REST message from a Scheduled script:


find_real_file.png

 

find_real_file.png

 

find_real_file.png

 

Executing the script I've got this error:
"Cannot find default value for object."

Any idea?
Many thanks!

1 ACCEPTED SOLUTION

Hi,

seems issue with the execute method

check docs link below

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/sn_ws-namespace/c_RESTRespons...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Hi Nicolo,

The job is created in which scope?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

In the app scope both the script and the REST message.
I tryed and the api works fine:

find_real_file.png

I've notice right now that for every execution there are two errors one posted before, the other is:

org.mozilla.javascript.EcmaError: Cannot find default value for object.
Caused by error in <refname> at line 4

1: printLog2();
2: function printLog2() {
3: var r = sn_ws.RESTMessageV2('x_414554_nozomiapp.nozomi', 'get_assets');
==> 4: var response = r.execute();
5: gs.info('REST message');
6: }


so it seems the execute method throw: "Cannot find default value for object"

Hi,

seems issue with the execute method

check docs link below

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/sn_ws-namespace/c_RESTRespons...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Nicol_
Giga Contributor

I found it just missing the new in:

var r = new sn_ws.RESTMessageV2('x_414554_nozomiapp.nozomi', 'get_assets');

my bad 🙂