Difference between revisions of "Web service API"

From NetXMS Wiki
Jump to navigation Jump to search
m (Text replacement - "^" to "{{deprecated}}")
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
Web service API provides access to NetXMS via HTTP/HTTPS. API calls are REST-like (although not purely RESTful) and uses JSON for data exchange.
{{deprecated}}Web service API provides access to NetXMS via HTTP/HTTPS. API calls are REST-like (although not purely RESTful) and uses JSON for data exchange.


= Session Management =
= Session Management =
Line 43: Line 43:
Get all nodes and containers:
Get all nodes and containers:
  GET /objects?class=container,node
  GET /objects?class=container,node
Get DCI Summary adHoc
POST /summaryTable/adHoc
Post payload:
<pre>
{
    "baseObject":"ContainerName",
    "multiInstance":false,
    "columns": [
        {
        "columnName":"Free form name that will be used in return table for this column",
        "dciName":"Name of DCI, that will be used for filtering"
        },
        {
        "columnName":"Name2",
        "dciName":"DCIName2"
        }
    ]
}</pre>


== Get Specific Object ==
== Get Specific Object ==
'''GET''' /objects/''id''
'''GET''' /objects/''id''


== Get Last Values for Object ==
'''GET''' objects/''id''/lastvalues


== CURL Test ==
== CURL Test ==
Line 81: Line 103:
.. prints some data ..
.. prints some data ..
</pre>
</pre>
= Java 10 =
If curl test works but grafana returns "Internal error" ({"description":"Internal error","error":46}")<br>
Add "--add-modules java.xml.bind" to JAVA_OPTS in /etc/default/tomcat8

Latest revision as of 18:14, 13 September 2022

This Wiki is deprecated and we are are currrently migrating remaining pages into product documentation (Admin Guide, NXSL Guide)

Web service API provides access to NetXMS via HTTP/HTTPS. API calls are REST-like (although not purely RESTful) and uses JSON for data exchange.

Session Management

Login

POST /sessions

Create new session. Input object fields:

login password

On success server will set cookie session_handle which should be passed on each subsequent request.

Logout

DELETE /session/sid

Logout (delete session) with given session ID.


Object Management

Get Objects

GET /objects GET /objects?filter

Get all objects visible to logged in user. Optional filter can define additional criteria for object selection:

area=geographical_area

class=class_list

name=pattern

Examples

Get all objects with name starting with "T":

GET /objects?name=T*

Get all nodes around Riga:

GET /objects?class=node&area=57.0592,23.1647,56.8270,24.6025

Get all nodes and containers:

GET /objects?class=container,node

Get DCI Summary adHoc

POST /summaryTable/adHoc

Post payload:

{
    "baseObject":"ContainerName",
    "multiInstance":false,
    "columns": [
        {
        "columnName":"Free form name that will be used in return table for this column",
        "dciName":"Name of DCI, that will be used for filtering"
        },
        {
        "columnName":"Name2",
        "dciName":"DCIName2"
        }
    ]
}

Get Specific Object

GET /objects/id

Get Last Values for Object

GET objects/id/lastvalues

CURL Test

Test API with Curl

$ curl -X POST --data '{"login":"user","password":"pass"}' "http://localhost:8080/netxms-websvc/sessions"

{
  "sessionHandle": "8338e7f3-ba99-46c5-9fd6-84b38cc5d715",
  "session": {
    "server": {
      "address": "127.0.0.1",
      "version": "2.2.8",
      "color": "",
      "id": 3283229296059149299,
      "timeZone": "CET+02CEST"
    },
    "user": {
      "name": "user",
      "id": 8,
      "globalAccessRights": 825439032336
    },
    "encrypted": false,
    "objectsSynchronized": false,
    "passwordExpired": false,
    "zoningEnabled": false
  }
}

$ curl -X GET --cookie "session_handle=8338e7f3-ba99-46c5-9fd6-84b38cc5d715" "http://localhost:8080/netxms-websvc/objects?class=container,node"

.. prints some data ..

Java 10

If curl test works but grafana returns "Internal error" ({"description":"Internal error","error":46}")
Add "--add-modules java.xml.bind" to JAVA_OPTS in /etc/default/tomcat8