how to consume rest api data in serviceportal what steps to follow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2020 09:43 PM
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.
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2020 09:58 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2020 12:31 AM
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));
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2020 07:54 AM
Worked for me!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2020 11:29 AM
I am trying to do similar thing. How can I pass parameter in this method?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2020 12:09 PM
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}