Forum Discussion

jegan's avatar
6 years ago

SDT - API issue

Hello Team,

 

Am trying to set SDT for service instance using API which is recommended in  https://www.logicmonitor.com/support/rest-api-developers-guide/v1/sdts/add-sdts/?_ga=2.235131781.507960210.1562148622-1055941791.1554297364 site. When I run script am getting below error. Could you please help me on this where I am doing mistake. 

 

Error

Response Status: 200
Response Body: {"data":null,"errmsg":"No such Website","status":1400}
 

 

Script content 

 

#Request Info
httpVerb ='POST'
resourcePath = '/sdt/sdts'
data = '{"sdtType":1,"type":"ServiceSDT","serviceId":119,"startDateTime":1562321776000,"endDateTime":1562408176000}'

#Construct URL
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
hmac = hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest()

signature = base64.b64encode(hmac)

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + 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
 

1 Reply

Replies have been turned off for this discussion
  • Based on the error message "No such Website" I would verify that serviceId 119 is valid and the correct id of an individual website check and not a website group or resource.