This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Discover Interfaces on a Node using the REST API

FormerMember
FormerMember

Hello,

Can somebody guide me on how to do this? I know we have to use the Invoke verb and Orion.NPM.Interfaces/DiscoverInterfacesOnNode as the SDK document states. Should I pass the DiscoverInterfacesOnNode in the URI like

xx.yy.zz.aa:17778/.../DiscoverInterfacesOnNode

or do I need to pass them as JSON? and how do I pass the node that I want to discover interfaces on?

Thank you,

Nuruddin

  • Hi,

    Yes, you need to pass it as JSON. Provided curl example below to achieve the same. Here NodeID 1 is provided as input.

    curl -k -u admin: -X POST -H "Content-Type: application/json" "https://localhost:17778/Solarwinds/InformationService/v3/json/Invoke/Orion.NPM.Interfaces/DiscoverInterfacesOnNode" --data "["1"]"

  • FormerMember
    0 FormerMember in reply to madhavan

    Hello Madhavan,

    JSON requires the following format : {"key" : "value"}. So what key should I use for the nodeId?

    Thanks,

    Nuruddin

  • ["1"] is a valid JSON. I tested the sample provided and it worked fine for me, try that and let me know if there is any issue.

  • FormerMember
    0 FormerMember in reply to madhavan

    Thank you. I had to pass in a JSONArray and not a JSONObject and it worked.

    Nuruddin

  • Hi,

    can you give me an idea

    how can i add the guid, script, username to this url in c# ?

    https://localhost:17778/SolarWinds/InformationService/v3/Json/Invoke/Cirrus.ConfigArchive/Execute

    Best Regards,

  • FormerMember
    0 FormerMember in reply to leinhard

    I have not used this api yet, and I code in Java. However, C# should be close to java. Assuming that the params are sent in an array, the structure should look like (I think from looking at the entity in SWQL):

    [ [guids], script, userid ]

    Using the jettison json api (java):

    JSONArray parameters = new JSONArray();

    JSONArray guids = new JSONArray();

    guids.put(guid);

    parameters.put(guids);

    parameters.put(script);

    parameters.put(userid);

    //send the parameters in the post like (in java using jersey api)

    resource.post(JSONObject.class, parameters);

    Hope this helps,

  • 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();

  • Thank you very much,

    your solution helpfull :-)

  • Thank you very much,

    test with your source now, :-),