Forum Discussion

Lewis_Beard's avatar
3 years ago

logicmonitor_sdk ... what do I do with api responses (getDeviceList)

https://www.logicmonitor.com/support-files/rest-api-developers-guide/sdks/docs/#api-LM-getDeviceList

I'm new to using the logicmonitor_sdk so forgive me for this newbie question. I usually find the LM API and SDK documentation I see to be a bit simple, or maybe I'm just not up to the level I'm expected to be. :)/emoticons/smile@2x.png 2x" title=":)" width="20" />

So I can successfully create a filter to call getDeviceList and I get an api response and I can print it out, just like the example, basically. And I can see when I print the response that its basically json.

But when I import the json library and try to interact with the response, I get an error "JSON object must be str, bytes or bytearray, not DevicePaginationResponse".

      api_response = api_instance.get_device_list(fields=fields, filter=filter)

 

What I want to ask is, where is the documentation to tell me what comes back from these logicmonitor_sdk calls?

Literally NONE of the api docs on the link above that I spot checked had an example of how to interact with response. At least that I saw.

Help? :)/emoticons/smile@2x.png 2x" title=":)" width="20" />

 

Thanks!

 

  • Not sure if this really answers your question but i am also new (less than 6 months) but i generally look at their swagger page to see what I can do with API and LM

    Swagger UI (logicmonitor.com)

    I also use powershell.  But examples of what i have done is use the api to get all devices of a folder ....then loop through them to add a custom property.  Also used API to get a list of Device IDs by device name, then loop through them to create an SDT for about 1000 servers.  

    It takes work but it's useful.  

  • Thanks for the responses, yall. Once I knew I could do the .to_dict() everything else was easy.

    Well, it was a little weird interacting with the system properties because I had to pull that out and iterate through all the name/value pairs and build my own sub-dictionary.

    But it all worked out. Thanks.

    In case anyone was interested in the general thing I was trying to do, I needed to know what some attributes were on some items that came back in the affected_items.csv on an AppliesTo. So I wrote a script to make a call to each device in the affected_items.csv and then make my own csv that has all the staticgroups so I could analyze those.

    Thanks everyone!

  • Anonymous's avatar
    Anonymous
    On 5/31/2022 at 10:32 AM, Lewis Beard said:

    I had to pull that out and iterate through all the name/value pairs and build my own sub-dictionary.

    Yes, that part sucks. Not sure why that doesn't just come back properly.