Outbound REST request fails with no error message

karanpreet
Tera Guru

Hi,

I'm trying to trigger a business rule which executes on addition of notes/additional comments on an incident and should Ideally send the latest note through the REST API to another system.

I've created a business rule which executes okay but I'm getting nothing in the REST response. This is what I get in the debugging:

02:27:16.460: : Content:

02:27:16.461: : Request Body: [object RESTResponseV2]

02:27:16.462: : Response:

02:27:16.463: : HTTP Status: 0

02:27:16.464: : Error Message:undefined

The script in the business rule is as follows:

function onAfter(current, previous)

{

var r;

var response;

var responseBody;

var httpStatus;

var message;    

try {

r = new sn_ws.RESTMessageV2('global.send_test', 'put');

response = r.execute();

responseBody = response.getBody();

httpStatus = response.getStatusCode();

}

catch(ex) {

message = ex.getMessage();

}

gs.info("Content: " + current.work_notes.getJournalEntry(1));

gs.info("Request Body: " + response);

gs.info("Response: " + responseBody);

gs.info("HTTP Status: " + httpStatus);

gs.info("Error Message:" + message);

}

The Outbound REST 'send_test' used above looks like this:

find_real_file.png

find_real_file.png

find_real_file.png

I'm new to service now and would really appreciate any help!

Regards,

Karan

1 ACCEPTED SOLUTION

karanpreet
Tera Guru

Hi,



I know this is an old question but since I was able to resolve it I thought I'll update it here as well.



Turns out the Service now instance wasn't able to reach the endpoint as it was behind a firewall. I got the details of the Mid server and once I routed the request through the mid server it went through fine.



Regards,


Karan


View solution in original post

5 REPLIES 5

ramireddy
Mega Guru

I don't find any error with the code or the way you setup REST message. Can you test your web service with "Post Man"?



Postman - Chrome Web Store



If you web service is working with Post man, try removing 'global.'



r = new sn_ws.RESTMessageV2('send_test', 'put');


Hi Ram,



I am able to send the same REST request through 'POSTMAN' and other such clients and they are successful.



But the request sent through SNOW gives me the same result. I even tried removing the 'global' keyword from the script but got the same response.



Regards,


Karan


Hi Karan,



In REST Messages, if you go to corresponding method, you can see a link "Test". Can you use that link to test the method and see what response you are getting. This doesn't require you to write code. Also do you have any logs defined at your web service? Whether the request is received or not?



Screen Shot 2016-07-27 at 1.03.26 pm.png


Thanks


Rami reddy


karanpreet
Tera Guru

Hi,



I know this is an old question but since I was able to resolve it I thought I'll update it here as well.



Turns out the Service now instance wasn't able to reach the endpoint as it was behind a firewall. I got the details of the Mid server and once I routed the request through the mid server it went through fine.



Regards,


Karan