Forum Discussion
Just in case someone finds this later, it seems that v1 just didnt do it. I switched to v3 using the header, and converted my patch data to json compatible (swapping single quotes for doubles) and it worked fine (I had tried the json format on the single quote version in my OP under v1 and it didnt work).
Here is the final code fragment, in case anyone is interested. I changed 3 things, more or less: 1) resource path changed to v3 style, 2) headers have v3 info in them, 3) I converted the re-built collector properties to json style with json.dumps.
#update the COLLECTOR CONTEXT if required
if c_update_required == True:
#build request (API v3)
patch_data = '{"customProperties": ' + json.dumps(new_collector_properties) + '}'
http_verb ='PATCH'
resource_path = '/setting/collector/collectors/'+collector_id
query_params =''
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resource_path + query_params
epoch = str(int(time.time() * 1000))
requestVars = http_verb + epoch + patch_data + resource_path
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version': '3'}
patch_response = lm_session.patch(url, data=patch_data, headers=headers)
if patch_response.ok:
(etc)
Related Content
- 9 months ago