CSV exports with tabular data
Most often, when people export to a csv or excel format their intent is to receive table data in a tabular format because they're going to pivot it out, chart it, or conduct some sort of analytics/BI function. It would be nice if your csv exports didn't require manipulation of the data to remove erroneous data/whitespace for consumability as a table datasource. This is specifically a problem in Website Overview reports.7Views2likes1CommentCreating dynamic group
Hi All I am trying to create groups with a pythonscript which read a CSV file. my txt file has following information {"name":1","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} {"name":2","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} {"name":3","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} {"name":4","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} when I run the script bellow I receiveInvalid JSON body message Response Status: 200 Response Body: b'{"data":null,"errmsg":"Invalid json body","status":1007}' I can create the group if I assign value directly like data ='{"name":1","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"}' Script is Quote Quote import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='tba' AccessKey ='XXX' Company = 'YYY' #Request Info httpVerb ='POST' resourcePath = '/device/groups' with open('test.txt', 'r') as file: #csv_reader = csv.reader(csv_file) for line in file: data =line print (data) url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #Get current time in milliseconds epoch = str(int(time.time() * 1000)) #Concatenate Request details requestVars = httpVerb + epoch + data + resourcePath #Construct signature hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest() signature = base64.b64encode(hmac1.encode()) #Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.post(url, data=data, headers=headers) #Print status and body of response print ('Response Status:',response.status_code) print ('Response Body:',response.content)3Views0likes0Comments