NetXMS Support Forum

English Support => General Support => Topic started by: Sch.Donat on August 27, 2020, 04:02:41 PM

Title: Web API alarm list for single node
Post by: Sch.Donat on August 27, 2020, 04:02:41 PM
Hi all!

I tried out the web API interface (3.4.313 server and 3.4.318 web API version). Getting the full alarm list worked fine, but when I want to query a single node, the request is returned with status code 405 (method not allowed) and with body:
{
    "description": "Internal error",
    "error": 46
}


The path used is <ip>/netxms-websvc/alarms/<nodeid>

Am I using the wrong path?

Regards
Title: Re: Web API alarm list for single node
Post by: Filipp Sudanov on August 31, 2020, 04:27:33 PM
Hi!

The way you tried is not yet implemented. What works is this way:

/alarms?objectId=123

/alarms?objectGuid=XXX

If you need to see alarms for all nodes under a container:
/alarms?objectId=123&includeChildObjects=true
Title: Re: Web API alarm list for single node
Post by: Sch.Donat on September 01, 2020, 07:33:37 PM
Hi!

Thanks, this way it works.
Is it possible to only query alarms from a given time period, or those that were generated in the last X seconds? Adding the filters from DCI querying doesn't seem to work.

Best regards
Title: Re: Web API alarm list for single node
Post by: Filipp Sudanov on September 02, 2020, 12:43:02 PM
Yes, you can use createdBefore, createdAfter, updatedBefore, updatedAfter. Unix timestamp should be provided to these filters.

Also, you can filter by alarm state, e.g.
alarm=outstanding
or
alarm=outstanding,acknowledged

And there's a good thing resolveReferences=true, in this case you'll have names of all related objects in the json output.

There are also filters by user name, you can check in sources for these: src/client/nxapisrv/java/src/main/java/org/netxms/websvc/handlers/Alarms.java

Title: Re: Web API alarm list for single node
Post by: Sch.Donat on September 02, 2020, 04:15:17 PM
It works great, thank you!