Forum Discussion

cvl's avatar
cvl
Icon for Neophyte rankNeophyte
4 months ago

addDevice API

Hi, 

I have used the above API and I can successfully add the device to LM, however I am unable to add it to a specific device group chain. 

I used <host_group_ids= '15,14,54',> in the body and I get the below error.

HTTP response body: {"errorMessage":"Unable to add the host into an auto group, appliesTo=isMisc()","errorCode":1500,"errorDetail":null}

Pease can you help me with what property needs to be populated to achieve what I need.

 

Thankyou.

 

  • cool, I figured it out: I was using the entire folder tree structure but I just needed the last element , i.e. 54

  • Note that turning off auto-assign devices it will also clear out that group/folder so it will be empty. It doesn't delete the actual devices, they will show up elsewhere, but might surprise you if you don't fully understand what are dynamic groups and how they work.

    • Anonymous's avatar
      Anonymous

      Are you sure about that? I just created a dynamic group that populated, then unchecked the box. The group turned static and has all those members in it still.

      • Mike_Moniz's avatar
        Mike_Moniz
        Icon for Professor rankProfessor

        Sorry, your correct. I see even the new UI shows a message stating that is the case too.

  • Anonymous's avatar
    Anonymous

    If group 15, 14, or 54 is a dynamic group, you can't add it to that group via the API. It will be added to the group if it meets the group's AppliesTo rule.

  • Thanks Stuart, 

    That helps, how do I change my device group to a manual group?

     

    Regards

     

    Conrad

    • Anonymous's avatar
      Anonymous

      In the UI, just uncheck the "Auto-assign devices" check box on the group's manage dialog. Keep in mind though that devices will no longer be automatically added to the group even if they satisfy the rule.

  • Just checked ,

    and the Auto-assign devices was already unchecked?

     

    • Anonymous's avatar
      Anonymous

      You were trying to add it to 3 groups, did you check all three groups?

  • yes , I did. All three have that disabled.

    this is the body, I was using.

    body = logicmonitor_sdk.models.Device(

        display_name='GenesysDevice',  # String | required | example: "Cisco Router"

        name='9.8.8.9',  # String | required | example: "Main Collector"

        preferred_collector_id=5,  # Integer | required | example: 2.0

        disable_alerting=False,  # Boolean | example: True

        auto_balanced_collector_group_id=0,  # Integer

        preferred_collector_group_id=2,  # Integer

        host_group_ids='17,53,54',

        system_properties=[{'name': 'system.staticgroups',

                            'value': 'Customers/GenesysCustomer/Telephony'}

                           ],

        custom_properties=[{'name': 'api.pass', 'value': '********'},

                           {'name': 'api.user', 'value': 'user'},

                           {'name': 'system.categories', 'value': ''}],  # Array

        description='Genesys',  # String | example: "This is a Cisco Router"

        user_permission='write',  # String

        preferred_collector_group_name='K.P',  # String

    )

  • cool, I figured it out: I was using the entire folder tree structure but I just needed the last element , i.e. 54

    • Anonymous's avatar
      Anonymous

      Ah yes, trying to add it with all three group IDs would try to add it to each group, not just the last one.

      Also, I'm curious if the setting of system_properties worked. It shouldn't.