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.

SWIS REST/JSON API

Starting with NPM 10.4, SWIS now supports a REST/JSON API in addition to the existing SOAP API. The operations supported by each API are identical: the six basic operations of Query, Invoke, Create, Read, Update, and Delete; and the data you can access through each API is the same. The difference is that the REST/JSON API avoids the complexities of XML and SOAP, though it gives up the ability to have a client wrapper generated from WSDL.

Both APIs will be supported by the product indefinitely - the SOAP API is not deprecated or replaced by the REST API.

Request and Response Formats

Query

Request

GET localhost:17778/.../Query HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*

Response

HTTP/1.1 200 OK
Content-Length: 244
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:38:52 GMT
{"totalRows":13,"results":[{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=4"},{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6"},{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=7"}]}

Body reformatted for easier reading
{

    "totalRows": 13,

    "results": [

        { "Uri": "swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=4" },

        { "Uri": "swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6" },

        { "Uri": "swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=7" }

    ]

}

Query with Parameters

Request

POST localhost:17778/.../Query HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 130
{"query":"SELECT Uri FROM Orion.Pollers WHERE PollerID=@p ORDER BY PollerID WITH ROWS 1 TO 3 WITH TOTALROWS","parameters":{"p":9}}

Response

HTTP/1.1 200 OK
Content-Length: 99
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 07 Aug 2012 17:36:27 GMT
{"totalRows":1,"results":[{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=9"}]}

Invoke

Request

POST localhost:17778/.../GetAliases HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 39
["SELECT B.Caption FROM Orion.Nodes B"]

Response

HTTP/1.1 200 OK
Content-Length: 19
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:23:27 GMT
{"B":"Orion.Nodes"}

The Metadata.GetAliases verb takes one string argument and returns a PropertyBag.

Create

Request

POST localhost:17778/.../Orion.Pollers HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 92
{"PollerType":"hi from curl 2", "NetObject":"N:123", "NetObjectType":"N", "NetObjectID":123}

Response

HTTP/1.1 200 OK
Content-Length: 69
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:27:11 GMT
"swis:\/\/tdanner-dev.swdev.local\/Orion\/Orion.Pollers\/PollerID=19"

Read

Request

GET localhost:17778/.../PollerID=6 HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*

Response

HTTP/1.1 200 OK
Content-Length: 245
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:30:02 GMT
{"PollerID":6,"PollerType":"V.Details.SNMP.Generic","NetObject":"V:1","NetObjectType":"V","NetObjectID":1,"DisplayName":null,"Description":null,"InstanceType":"Orion.Pollers","Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6"}

Update

Request

POST localhost:17778/.../PollerID=6 HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 29
{"PollerType":"hi from curl"}

Response

HTTP/1.1 200 OK
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:32:06 GMT

Delete

Request

DELETE localhost:17778/.../PollerID=16 HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*

Response

HTTP/1.1 200 OK
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:37:33 GMT
  • Does anyone have an example of how to get this into a C# application ?

  • Here's a quick and dirty C# client that does queries. Hopefully that will be enough to get you started.

    CSharpSwisJson.zip
  • My select query is working:

    JObject results = client.Query("SELECT NodeID, Comments FROM Orion.NodesCustomProperties WHERE NodeID = 469",new JObject {{"vendor", "Cisco"}});

    However I can't get an update query to work to do the actual change.

    JObject results = client.Query("UPDATE Orion.NodesCustomProperties SET Comments= 'It Worked' WHERE NodeID = 469", new JObject { { "vendor", "Cisco" } });

    Error: (400) Bad Request

    I am using Json.NET 4.5.0.0

    Thanks,

    Richard

  • Does anybody have a quick and dirty PHP client, prehaps? I'm just trying to do straight HTTPRequest using a client for Chrome:

    I get:

    Response does not contain any data.


    My Request:

    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36

    Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo

    Authorization: Basic YWRtaW4=

    Content-Type: application/x-www-form-urlencoded

    Accept: */*

    Accept-Encoding: gzip,deflate,sdch

    Accept-Language: en-US,en;q=0.8

    Cookie: ASP.NET_SessionId=xpcllv0adkiikknl3pjalh44; SelectedTab=3; Orion_IsSessionExp=TRUE; __utma=1.895714814.1391008906.1391021778.1392054254.3; __utmb=1.29.10.1392054254; __utmc=1; __utmz=1.1391008906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); .ASPXAUTH=15EA7F01540DEDED02766145CA7E47C1B6169B986CD2E6B318D5045C0E438D7679FAF5764C0F55B7DA9D249188E6DDEBF89D84866F1580E3846141B72E429D8A2842DB6C602291AE0770744E1E830B4C537EF2BC7BD2F65162CC588FDDCE42CE125591D8E399E04A96F0E849
    Payload: query=SELECT+Caption+FROM+Orion.Nodes+WHERE+NodeID%3D1

  • The Content-Type should be "application/json", and the payload should be this:

    { "query": "SELECT Caption FROM Orion.Nodes WHERE NodeID=1" }

    You don't need the cookie, but I suspect that was added by the Chrome extension you are using.

    What URL are you POSTing to? It should be https://servername:17778/SolarWinds/InformationService/v3/Json/Query

  • Sorry, I should've provided the URL emoticons_happy.png

    I've tried:

    https://10.10.10.6:17778/SolarWinds/InformationService/v3/Json/Query

    https://10.10.10.6/SolarWinds/InformationService/v3/Json/Query

    Both of which, if I try to go to in a browser page instead of HTTPRequest Client, I'll hit the HTTP authorization dialogue, log in and then get a blank page

  • In words, what are you trying to do, "Select NodeID and comments from Orion.NodesCustomerProperties, but only where NodeId is 469 " and then what?

  • Looks like I missed this question in December. Sorry about that, Richard! And thanks Kevin for reviving it.

    The SWIS query interface is strictly readonly. You can't update this way.

    However, you can set custom property values through an update call. Make a POST request to https://servername:17778/SolarWinds/InformationService/v3/Json/swis://servername/Orion/Orion.Nodes/NodeID=469/CustomProperties with a body containing:

    { "Comments": "It worked" }

  • Ok, the first URL (on port 17778) looks correct. Visiting it in a browser won't do anything for you - it has no page to show.

    Did you fix the payload format to be JSON?

  • This is an old post emoticons_happy.png I got it working in PHP, remember?