How can i call REST API (3rd party) from my UI page in client script or Jelly script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 12:23 AM
Actually I have a dialogue window (pop up) and have a drop down in that window. I want to update this combo-box (drop down) with the data coming from REST API.
Please help me to achieve this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 01:39 AM
Hi Randeep,
Could you use the approach here
Sending data from SN to an Identity Management Platform via SOAP
but instead of calling SOAPmessage()
call RESTMessageV2
Best Regards
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 02:13 AM
Hi Tony,
Can i call this in client side script ? the following code is correct ? I want to load this data into a combo box while we are calling the dialogue window first time ,,
$j(document).ready(function () {
// Call RESTAPI here ?
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 03:07 AM
it seems you are using jquery in your page so you can use ajax method of jquery to make rest calls.
http://api.jquery.com/jquery.ajax/
alternativly you can use $http method of angular JS. but since you have jquery Out of box in servicenow go for jquery if it is small page.
i hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 03:59 AM
Hi Randeep,
You can use jquery in client scripts. following code is an example GET REST request . for additional details about ajax request http://api.jquery.com/jquery.ajax
$j(function() {
var request = $j.ajax({
type: "GET",
url: url1, // REST endpoint. replace url1 with REST Endpoint
// data : {},//json data. use data and contentType attributes for POST requests.
// contentType: "application/json",
dataType: "json",
/*xhrFields: {
'withCredentials': true //Tell browser to provide credentials
},
crossDomain: true,// this is for cross domain requests*/
success: function (data,status,jqXHR){
console.log("status:"+status);
},
error: function (jqXHR,status){
console.log("failed: "+jqXHR+"\nstatus:"+status);
},
complete : function(jqXHR,status)
{
console.log("status: "+status);
}
});
});