Dynamic outbound REST that consumes multiple endpoints
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 12:14 AM
Hi,
I have 20+ integration end points. Assumption is all these integrations use REST APIs and the integration list can grow.
I am trying for an easy and instant way to integrate with all these integrations, so that we would be able to build a new integration with a less effort.
Can someone guide me or point me on how to achieve this.
Thanks & Regards,
Phani
- Labels:
-
Instance Configuration
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 03:25 AM
Dear Phanindra,
This can be achieved with a single server-side script. e.g.
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://XXXX.service-now.com/api/now/v1/table/incident?sysparm_query=active%3Dtrue%5Epriority%3D1&sysparm_limit=10');
Here, you can set the endpoint dynamically everytime with a loop.
Hope, this will help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 04:08 AM
Hi Subhankar,
Firstly thanks for your response.
I have already done a bit of work on this. I have created a table to store end point details and then from a business rule trigger a rest message which calls the table. However, I am struggling with the authentication.
//BR running on incident table whenever assignment group is not blank.
var i= new GlideRecord('u_configure_integrations');
i.addQuery('u_group',current.assignment_group);
//if there is a matching record in Configure_integrations table where group is same as task's assigned group.
i.query();
if(i.next()){
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('POST');
r.setEndpoint(i.u_integration_end_point);
var user = i.user_name;
var password = i.password; //password(2 way encrypted) field type
r.setBasicAuth(user,password);
r.setRequestHeader("Accept","application/json");
r.setRequestHeader('Content-Type','application/json');
r.setRequestBody("{\"u_id\":\""+current.number+"\",\"u_short_description\":\"Test205\"}");
var response = r.execute();
}
However, I am getting an authentication error when connecting to the end points. I think, its to do with reading the 'password field type' field value as
I am getting sucessful response when I hard code password in the script.
Any help plz?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 04:46 AM
Hi,
You have to decrypt your password field. For that you can use this code:
var _pass=new GlideEncrypter().decrypt(i.password);
--
Cheers,
AR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 04:52 AM
I think this input will help Phanindra to resolve the issue.