API request doesn't return all objects..
I am trying the API request with the following (skipping authentication header below and other non relevant parts):
....
company = d['company']
access_id = d['access-id']
access_key = d['access-key']
#Request data for alerts
httpVerb ='GET'
resourcePath = '/alert/alerts'
queryParams ='?offset=0&size=1000'
data=''
#construct URL
url = 'https://' + company + '.logicmonitor.com/santaba/rest' + resourcePath + queryParams
....
Authentication is going fine and I get "200 response".
But JSON returned does not have all objects.
It starts like this:
{
"status" : 200,
"errmsg" : "OK",
"data" : {
"total" : 238,
"items" : [ {
"id" : "DS5957680",
"type" : "dataSourceAlert",
"internalId" : "LMD659437",
"startEpoch" : 1660495929,
"endEpoch" : 0,
"acked" : false,
"ackedEpoch" : 0,
"ackedBy" : "",
"ackComment" : "",
So , I am expecting 238 objects, but it show only 4 and interrupted on the 5th
} ],
"resourceId" : 23853,
"resourceTemplateId" : 650,
"resourceTemplateType" : "DS",
"resourceTempl
Have anybody seen this stuff? What could be wrong here?
Python request module usage requires additional tuning?
- Anonymous2 years ago
Output the URL and your headers to your screen and verify the same behavior in postman. If it does the same thing in postman, it's a problem with the API. If postman fetches it just fine, it's your script.
If you're using python, consider using the SDK. Much easier:
alerts = lm.get_alert_list(size=1000,offset=0).items
If you need pagination (because there are more than 1000 items):
alerts = [] end_found = False offset = 0 size = 1000 while not end_found: current = lm.get_alert_list(size=size, offset=offset).items alerts += current offset += len(current) end_found = len(current) != size