EvanTempel
2 months agoNeophyte
LM API
Interesting in hearing some use cases you guys have for the LM API? I have a few scripts setup for mass device manipulation in the case of a change, mass auto discovery, automatically add a Windows ...
While you are on the scripts topic :) I'm needing some help please :) I'm trying to rename a group of devices to use FQDN on the name property and its not quiet working. deviceName gets the response i want, it returns 'server.somedomain.local' but when i try to use deviceName in the data variable value of "name" its not working it returns '("name":deviceName)' I know I'm missing something simple ??
#Loop through each device & update name
for i in jsonResponse['data']['items']:
deviceId = str(i['id'])
deviceName = str(i['displayName']) + ".somedommain.local"
#Request Info
httpVerb ='PATCH'
resourcePath = '/device/devices/'+deviceId
queryParams ='?patchFields=name'
data = '("name":deviceName)'
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams