0

I have done Javascript and html 20yrs back and almost forgot howtos. So Please excuse me for ignorance. Also lot of things and syntax seems to have changed.

My requirement:

  1. Pull server Data from Solarwinds API
  2. Put it in a Dual List Box with Search options :)
  3. User Select the server they want to put in maintenance from list box (move from left list box to right list box)
  4. Select a From and To (Date time picker)
  5. Submit to API for muting alerts for the servers selected

First I am trying to get the data from the Solarwinds API and to my utter dismay I can't even show the data in a page :(. I am able to fetch the data using Postman. My webserver is IIS

var myHeaders = new Headers();
myHeaders.append("User-Agent", "curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3");
myHeaders.append("Access-Control-Allow-Origin", "*");
myHeaders.append("rejectUnauthorized", "");
myHeaders.append("Authorization", "Basic blahblahblhablhablahblah");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://serverHostName.net:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+Caption,+IPAddress,+NodeID,+Uri+AS+[EntityUri]+FROM+Orion.Nodes+WHERE+Vendor+=+'Windows'", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

My HTML looks like below

<!DOCTYPE html>
<html lang="en-US">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Maintenance Window</title>
    <link rel="stylesheet" href="style.css">
</head>
 
<body>

<script src="SolarwindsApiInteraction.js"></script>

</body> 
 
</html>

SADLY: I am getting a blank Page.

enter image description here

What I need is the publish the output of the Data in a Dual List box. The Json usually looks like below based on Postman output

{"results":[{"Caption":"ServerA","IPAddress":"5X.1XX.XX.XX1","NodeID":1,"EntityUri":"swis://ServerA.net/Orion/Orion.Nodes/NodeID=1"},{"Caption":"ServerB","IPAddress":"5X.1XX.XX.XX2","NodeID":2,"EntityUri":"swis://ServerA.net/Orion/Orion.Nodes/NodeID=2"},{"Caption":"ServerC","IPAddress":"5X.1XX.XX.XX8","NodeID":3,"EntityUri":"swis://ServerC.net/Orion/Orion.Nodes/NodeID=3"},{"Caption":"ServerD","IPAddress":"5X.1XX.XX.XX4","NodeID":4,"EntityUri":"swis://ServerD.net/Orion/Orion.Nodes/NodeID=4"},{"Caption":"ServerE","IPAddress":"5X.1XX.XX.XX5","NodeID":5,"EntityUri":"swis://ServerE.net/Orion/Orion.Nodes/NodeID=5"}]}

The nodeID can be the index in the listbox with ServerName as name in the listbox

  • What do you see in the console? – Nir Alfasi Mar 06 '23 at 14:25
  • Blank Page in the web portal. No data. Also a note. in postman I need to use SSL = Off as Solarwinds use self signed certificate – Anirban Banerjee Mar 06 '23 at 14:29
  • I asked what do you see in the console, not in the web portal. do you know what is the console tab on "dev tools" ? – Nir Alfasi Mar 06 '23 at 14:30
  • Sorry I am using notepad to append code. Do not have access to Dev Tools. I understand what you are saying and I know why I am not seeing any output in the portal. Now I need the data in a Listbox in portal. But That step 2. First step atleast we need to getthe output – Anirban Banerjee Mar 06 '23 at 14:50
  • OK i cannot figure out how to do this. In Postman i am able to get results. Converted into Javascript Fetch code. Called the script from a html page. It won't work on the same server :( any guidance will really help – Anirban Banerjee Mar 06 '23 at 18:31

0 Answers0