Christopher_Mal
ServiceNow Employee
ServiceNow Employee

If you happen to run into the following error within a scoped application: Error constructing REST Message/Method: The chances are you need to dereference the global namespace for your REST Message name.  

Here are the symptoms of this behavior.   You create a REST Message in global scope that is accessible to all Application Scopes.   You test it using the Test Related Link.

get___ServiceNow.jpg

It returns a beautiful 200 HTTP Status Code.   You use the Preview Script Usage and copy the contents to use within a scoped application.   It doesn't work.   You get the Error constructing REST Message/Method:.

You need to prefix your REST Message name with global (like so):

try {

var r = new sn_ws.RESTMessageV2('global.rest_message_name', 'get');

var response = r.execute();

var responseBody = response.getBody();

var httpStatus = response.getStatusCode();

}

catch(ex) {

var message = ex.getMessage();

}

7 Comments