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):
<span class="pln">....
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
....</span>
Authentication is going fine and I get "200 response".
But JSON returned does not have all objects.
It starts like this:
<span class="pln">{
"status" : 200,
"errmsg" : "OK",
"data" : {
"total" : 238,
"items" : [ {
"id" : "DS5957680",
"type" : "dataSourceAlert",
"internalId" : "LMD659437",
"startEpoch" : 1660495929,
"endEpoch" : 0,
"acked" : false,
"ackedEpoch" : 0,
"ackedBy" : "",
"ackComment" : "",</span>So , I am expecting 238 objects, but it show only 4 and interrupted on the 5th
Have anybody seen this stuff? What could be wrong here?
Python request module usage requires additional tuning?
Denis_T
Posted 3 years ago·Last reply 3 years ago
7 comments
LM User
·3 years agoFancy IDEs and code editors are no match for notepad and terminal at your side.
Denis_T
OP3 years agoAnd finally I found what was "the issue".. It is just VS Code not printing the whole request reply if it's too long:).
LM User
·3 years agoCoolio. the method you want is .get_alert_list(size=1000,offset=0).items.
That documentation page is for v3 of the SDK which is newly released. I'm not sure they've noticed the navigation problems. For me, none of the links in the left frame even work. Here's the v2 documentation, which is pretty solid and probably matches up with v3 for the most part. While LM did release APIv3, I haven't noticed any of the endpoints I know exist (and use; call me a renegade) but that weren't available in v2. So, i haven't found a compelling reason to move to v3 of the api/sdk.
Denis_T
OP3 years agoI figured out that we can access the material by clicking in the middle of the page and scrolling (or using page search).
Denis_T
OP3 years agoAlso, I followed the advice from Stuart and put the Authentication header in Postman.
Return was good, 587K of JSON.
At least I know nothing is wrong with the API :)/emoticons/smile@2x.png 2x" title=":)" width="20" />
Denis_T
OP3 years agoThanks Stuart.
Regarding SDK:
I was trying to look into SDK, but it requires some authentication:
in here: https://www.logicmonitor.com/swagger-ui-master/api-v3/Python-SDK/lm-sdkv3-docs.html
it is sending me there:
https://bamboo.logicmonitor.com/browse/LM-SS-172/artifact/shared/Docs/index.html#api-Alerts-getAlertList
LM User
·3 years agoOutput 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:
If you need pagination (because there are more than 1000 items):