N-central Troubleshooting
How to get Last Scan Time for a device from N-able N-central API using SOAP calls
Last Modified
Mon Nov 30 16:57 GMT 2020
Description
- How to get last scan time for a device from N-able N-central API using SOAP calls
Environment
- N-able N-central
Solution
- See this article for assistance setting up the WSDL in your application of choice: Accessing N-able N-centralAPI functions
- Neither the Deprecated API call DeviceAssetInfoExport or its replacement (DeviceAssetInfoExportDeviceWithSettings in API2) returns the value desired 'last scan time'. Upon further checking it was found that these calls will return a list of devices (including deviceid's), which you can then use against the getDeviceStatus API call (NOT deprecated), to return the desired value.
//API v1
https://your_server_address_here/dms/services/ServerEI?wsdl
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mic="http://www.n-able.com/mickey" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<mic:DeviceGetStatus soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<Username xsi:type="xsd:string">productadmin@n-able.com</Username>
<Password xsi:type="xsd:string">***************</Password>
<Settings xsi:type="mic:ArrayOf_tns1_T_KeyPair" soapenc:arrayType="mic:T_KeyPair[]">
<T_KeyPair>
<key>deviceid</key>
<value>111111111</value>
</T_KeyPair>
</Settings>
</mic:DeviceGetStatus>
</soapenv:Body>
</soapenv:Envelope>
//soap response
...
<Info xsi:type="ns1:T_KeyPair">
<Key xsi:type="xsd:string">devicestatus.devicename</Key>
<Value xsi:type="xsd:string">ENTERPRISE</Value>
</Info>
...
<Info xsi:type="ns1:T_KeyPair">
<Key xsi:type="xsd:string">devicestatus.lastscantime</Key>
<Value xsi:type="xsd:string">2020-01-01 01:01:01.837 +0200</Value>
</Info>
//API v2
https://your_server_address_here/dms2/services2/ServerEI2?wsdl
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ei2="http://ei2.nobj.nable.com/">
<soap:Header/>
<soap:Body>
<ei2:deviceGetStatus>
<ei2:username>productadmin@n-able.com</ei2:username>
<ei2:password>********************</ei2:password>
<!--Zero or more repetitions:-->
<ei2:settings>
<ei2:key>deviceid</ei2:key>
<ei2:value>111111111</ei2:value>
</ei2:settings>
</ei2:deviceGetStatus>
</soap:Body>
</soap:Envelope>
//response
...
<info>
<first xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">devicestatus.devicename</first>
<second xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">ENTERPRICE</second>
<key>devicestatus.devicename</key>
<value>ENTERPRICE</value>
</info>
...
<info>
<first xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">devicestatus.lastscantime</first>
<second xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">2020-01-16 17:10:16.630 +0200</second>
<key>devicestatus.lastscantime</key>
<value>2020-01-01 01:01:01.630 +0200</value>
</info>