REST "Uncaught ReferenceError: sn_ws is not defined"

xiaix
Tera Guru

find_real_file.png

function testMe()

{

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

      console.debug("r: " + r);

     

      var response = r.execute();

      console.debug("response: " + response);

     

      var responseBody = response.getBody();

      console.debug("responseBody: " + responseBody);

     

      var httpStatus = response.getStatusCode();

      console.debug("httpStatus: " + httpStatus);

}

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi David,



You may find the below thread helpful.


Scope Question: Integration APIs - sn_ws


View solution in original post

10 REPLIES 10

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Perfect.


Can you please mark the thread answered if this resolves your issue.


Glad you got it figured out. FYI - best practice is to avoid using getXMLWait() and use getXML() when ever possible. getXMLWait() is synchronous and can hold the browser hostage while it waits for a response from the server. In most cases the user won't notice, but that's MOST cases, not all.


Ahhh... dam, I never knew that!   Thank you!


Great suggestion Chuck.


@David, Here are more tips on client side best practices.


Client Script Best Practices - ServiceNow Wiki


Great link.   http://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices#Example:_Asynchronous_GlideA... shows exactly what Chuck was referring to.   Thanks.