How to display data like device details, ip address..in our portal from the 3rd party through API in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 04:58 AM
Hi Team,
I am trying to implement this - When the user clicks on Device name mentioned in the portal, he/she should get all the details of that device from the 3rd party to our portal through api. how to implement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 06:59 AM
@Shivalika -No Its not about the catalog item,
I want to know the logic to display the details from 3rd party in my widget. the requirement is to get the device details from 3rd party through API.
1) I started with - we have API- so we did rest message- got token and received machine details from that-- this is clear.
2) now i got stuck how to display in portal with html, client side or server script.
3) Or is there way to right the rest message (preview script usage) directly in server script.
Kindly refer easy and best way to implement this with steps would be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 07:19 AM
Hello @nivethika
Yes, you can call the rest message directly in the widget's server script.
Use below 👇 function in server script -
(function() {
try {
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setEndpoint('API_ENDPOINT_URL'); // Replace with actual API URL
restMessage.setHttpMethod('get'); // Change to 'post', 'put', etc., if required
restMessage.setRequestHeader('Authorization', 'Bearer YOUR_ACCESS_TOKEN'); // Add necessary headers
var response = restMessage.execute();
var responseBody = response.getBody();
data.records = JSON.parse(responseBody); // Store API response for client-side use
} catch (ex) {
gs.error('Error calling API: ' + ex.message);
data.records = { error: ex.message };
}
})();
Use below 👇 code in HTML -
<div class="container">
<h2>Record Details</h2>
<div ng-if="data.records.error">
<p class="text-danger">Error: {{ data.records.error }}</p>
</div>
<table class="table table-bordered" ng-if="!data.records.error">
<thead>
<tr>
<th>Field 1</th>
<th>Field 2</th>
<th>Field 3</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="record in data.records">
<td>{{record.field1}}</td>
<td>{{record.field2}}</td>
<td>{{record.field3}}</td>
</tr>
</tbody
>
</table>
</div>
Please replace it with appropriate methods and variable names in your instance.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY