Using Scoped REST Message within scoped application

abuthahir
Tera Expert

Hi All,

I have an Outbound REST message to post. I have created it within the scoped application and i have table in the same scope. I am trying to run a business rule script to run this REST Message whenever there is a record inserted. Am setting the body in a perfect manner still its not happening. [httpStatus is 0]. When i try the same body in the rRST message "Test" functionality its working perfectly. May i know what is the issue.? Please let me know . ctomasipradeepksharma kalai

var r = new sn_ws.RESTMessageV2('rest message name', 'post');

  var body = '{"JSON Body comes here"}';

  r.setRequestBody(body);

  var response = r.execute();

  var responseBody = response.getBody();

  var httpStatus = response.getStatusCode();

1 ACCEPTED SOLUTION

I wasn't aware of that either. Thank you for sharing Abu.



The only reason I can think of for blocking it is because REST, but default is a synchronous operation. For example, if it takes 10 seconds to get a response from the remote REST host, your browser is stuck waiting in a before/after business rule and presents a poor user experience. Async rules process in the background so the user doesn't have to wait.


View solution in original post

10 REPLIES 10

abuthahir
Tera Expert

Do any one have suggestions please.


Kalaiarasan Pus
Giga Sage

I haven't worked much in scoped app but I would suggest that prefix the script include name with 'global.' and give it a try.


Chuck Tomasi
Tera Patron

When you are viewing the REST message record (in the post method) click the link Preview Script Usage and try that code as a starting point.



find_real_file.png


Hi Sir,


When i reached Servicenow team, they intimated that using any REST Message in After/Before business rule in a scoped application is blocked by Servicenow. Even they aren't aware about about the exact reason. But, the same works well in "Async" BR. Curious to know the reason why it is blocked by servicenow. Any inputs/suggestions will help me. Thanks