Quantcast
Viewing all articles
Browse latest Browse all 20518

Re: Re: Discover Interfaces on a Node using the REST API

Provided below is a sample, modify it according to your need. (I'm not sure about the parameters required for this verb)

You need "Newtonsoft.Json.dll" which is JSON helper. It can be used to serialize and deserialize json.

 

HttpWebRequest req = WebRequest.Create("https://localhost:17778/SolarWinds/InformationService/v3/Json/Invoke/Cirrus.Config/Archive/Execute") as HttpWebRequest;
req.KeepAlive = true;
req.Credentials = new NetworkCredential("admin", "");

req.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

dynamic p = new System.Dynamic.ExpandoObject();
p.guid = System.Guid.NewGuid();
p.username = "";
p.script = "";

string content = JsonConvert.SerializeObject(p);

byte[] buffer = Encoding.ASCII.GetBytes(content);
req.ContentType = "application/json";
req.Method = "POST";
Stream PostData = req.GetRequestStream();
PostData.Write(buffer, 0, buffer.Length);

HttpWebResponse resp = req.GetResponse() as HttpWebResponse;

Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader responseStream = new StreamReader(resp.GetResponseStream(), enc);

string Response = responseStream.ReadToEnd();

responseStream.Close();
resp.Close();

Viewing all articles
Browse latest Browse all 20518

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>