- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 03:47 AM
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:
I'm new to service now and would really appreciate any help!
Regards,
Karan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 05:20 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 04:03 AM
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"?
If you web service is working with Post man, try removing 'global.'
r = new sn_ws.RESTMessageV2('send_test', 'put');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 12:24 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 12:35 AM
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?
Thanks
Rami reddy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 05:20 AM
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