06-27-2016 12:05 PM - edited 06-27-2016 12:06 PM
I'm trying to find out the device_id of a device (and other fields) given a device name via webAPI.
Though I have a functional script using Perl API.
I'm not sure how do I use val_c_DeviceName and op_DeviceName in the weAPI link together?
I tried using below which failed terribly.
Ironically when I'm running this I'm getting a list of all the availabvle devices discovred by NetMRI.(I'm expecting 1 result not ALL)
Can someone explain?
Solved! Go to Solution.
06-27-2016 12:26 PM
show - requires the ID
index - you can filter on specific, indexed fields with equality. The specific fields are listed in the API docs for the index method for that particular type of object. For example, for Device, the DeviceName is one of those fields, so you can just do: /api/3/devices?DeviceName=my.device.name
search - like index, except you can search on ANY fields with equality. Note though that if you use a field other than the ones listed in ”index”, you will be doing a complete scan of the table, which is not efficient.
find - this is a more complex beast but allows you to do partial matches and other operations than ”equality”.
Your first example of ”find” would work if you used & not , between the first two parameters, and didn’t put any quotes:
06-27-2016 01:29 PM
For the detailed and prompt reply!!
Still have some question about search and index but 'find' did work for me.
01-20-2017 01:00 AM
if you use python, i made this function for this kind of need. i let it here, maybe it will help:
if device_name.lower() in d.lower():
DeviceID_field = DeviceID_right.partition("}")
print("WARNING: device: "+device_name+" does NOT exist in NETMRI")