Hi,
I have tried to use the API to retrieve multiple (ideally all) properties from a single device object and get no results (directly from the API builder in PRTG).
If I navigate to a device I can clearly see the object id is 12345
https://prtg/device.htm?id=12345&tabid=7
But when I try to use the API to retrieve device details I get no real data (other than basic XML with totalcount=0)
https://prtg/api/table.xml?content=devices&output=xml&columns=objid,group,device,name,status&count=10&id=12345
If I leave off the "id=12345" - I get back all device names. The help for the "id" field clearly states "The table will only contain information for this object id and its child objects (all objects will be used if this parameter is omitted)"
Am I missing something here?
Thanks, Steve
Article Comments
https://prtg/api/table.xml?content=devices&output=xml&columns=objid,group,device,name,status&count=10&id=12345
This request is not valid. To filter by ID you need to specify filter_objid=12345
Nov, 2019 - Permalink
lordmilko,
Thanks for the pointer - using the "filter_objid=" URL parameter has solved my problem accessing device properties in one go (rather than multiple API calls).
Sasa,
The PRTG API online help seems to incorrectly specify the use of "id=xxx" URL parameter to filter results. It is mentioned on the "Accessing Live Object Data and Live Status Data" page and used in the "XML Table Query Builder" if you specify an ID to return for the "Devices: List of all devices" test. This does not work (hence my original problem). Lordmilkos reply/help has pointed me to the correct parameter.
The use of the "ID=" parameter is also reference on the same page under the "Filtering by Object ID" section. It states "Add an ID parameter (for example, id=1) to the API URL to select a subset of items".
Clearly this did not work for me - and I can find no reference on the page to the use of "filter_objid="
Cheers, Steve
Nov, 2019 - Permalink
Hello Steve,
The problem was with the "content=devices", this will list all the devices that are under the object with the specified ID. Since the ID that you entered was from a device, you have received a empty result (since you can not have devices under a device). So the solution is to filter for the ID, as lordmilko suggested.
Nov, 2019 - Permalink
Hello Steve,
Thank you for your post.
What exactly do you want to have as a result? Do you want all the sensors that are in the device?
Can you give an example on how the output should look like?
Kind regards,
Sasa Ignjatovic, Tech Support Team
Nov, 2019 - Permalink