how to consume rest api data in serviceportal what steps to follow

Shilpi Sharma2
Tera Contributor

Hi All,

i have a new api and its working fine and giving data in json format now i want to consume that rest api output in service portal widget. 

9 REPLIES 9

Hi yes,

We can do that, but writing it in the SI would make it reuseable and easy for you if you need to reuse that rest call.

 

Regards

Omkar Mone

SatheeshKumar
Kilo Sage

 

In your widget client script use angular http method to make a rest call.

 

function($http) {
    /* widget controller */
    var c = this;
    
	
$http.get('https://dev51484.service-now.com/api/now/table/incident/cc7d9d04db8d8410b6db8e4748961944').then(function(response){
  alert(JSON.stringify(response.data.result));
 });

	 
}

 

 

 

Worked for me!

Hema Mistry
Tera Expert

I am trying to do similar thing. How can I pass parameter in this method?

Everything inside $http.get() is a string.

So, we can simply construct the required endpoint with an additional parameter.

var endpoint = 'https://dev51484.service-now.com/api/now/table/incident/' + Your value;

$http.get(endpoint);

 

In your REST message, declare like:

https://dev51484.service-now.com/api/now/table/incident/${parameter}