1 Reply Latest reply on Feb 11, 2017 6:59 AM by francis.yiu@atkinsglobal.com

    python add groupcustomproperties error

    francis.yiu@atkinsglobal.com

      Please help: code as following:

      site_info = {

          'ContainerID' : 1524,

          'SITE_ADDRESS' : siteAddress,

          'SITE_Address_City' : siteCity,

          'SITE_Address_Postcode' : sitePostcode,

          'SITE_Address_State' : sitestate,

          'SITE_Code' : 'Sample Python Group',

          'SITE_Country_Code' : siteCountry,

          'SITE_District' : siteDistrict,

          'SITE_Name' : 'Sample Python Group',       

          'SITE_Region' : siteRegion,

          'SITE_TimeZone' : siteTimezone,

          'SITE_Timezone_Observe_DST': siteDst,

          'SITE_TimeZone_Standard_UTC_Offset': siteUTCoffset,

          'SITE_Country_Name' : None,

          'VENDOR_AccountManager' : None,

          'VENDOR_AccountManager_Email' : None,

          'VENDOR_AccountManager_Telephone' : None,

          'VENDOR_ServiceDesk_Email' : None,

          'VENDOR_ServiceDesk_Telephone' : None,

          'VENDOR_ServiceManager' : None,

          'VENDOR_ServiceManager_Email' : None,

          'VENDOR_ServiceManager_Telephone' : None,

      }

      response = swis.create('Orion.GroupCustomProperties', **site_info)

      the content of site_info

      {'SITE_Country_Name': None, 'VENDOR_ServiceDesk_Telephone': None, 'SITE_ADDRESS': 'somewhere', 'SITE

      _Address_Postcode': 'E999', 'SITE_Country_Code': 'UK', 'VENDOR_AccountManager_Email': None, 'SITE_Ti

      meZone_Standard_UTC_Offset': 0, 'SITE_Name': 'Sample Python Group', 'VENDOR_AccountManager': None, '

      VENDOR_ServiceManager_Telephone': None, 'SITE_TimeZone': 'GMT', 'SITE_Code': 'Sample Python Group',

      'SITE_Timezone_Observe_DST': True, 'VENDOR_ServiceManager': None, 'SITE_Region': 'UK', 'ContainerID'

      : 1524, 'VENDOR_ServiceDesk_Email': None, 'SITE_Address_State': 'London', 'SITE_Address_City': 'Lond

      on', 'VENDOR_ServiceManager_Email': None, 'VENDOR_AccountManager_Telephone': None, 'SITE_District':

      'busy'}

       

      error message is

      requests.exceptions.HTTPError: 400 Client Error: Entity Orion.GroupCustomProperties does not contain

      any key properties.

      Parameter name: entityType for url: https://sgbd016191.wsatkins.com:17778/SolarWinds/InformationServ

      ice/v3/Json/Create/Orion.GroupCustomProperties

       

      What is key properties, please?

       

      Message was edited by: Francis Yiu Thanks for your information

        • Re: python add groupcustomproperties error
          tdanner

          To set custom properties, don't create an instance of Orion.GroupCustomProperties. This instance was automatically created when the group was created. To set the group's custom properties, you need to get the Uri of this instance and update it. Here's a quick and dirty example:

           

          from orionsdk import SwisClient
          swis = SwisClient('localhost', 'admin', '')
          x = swis.query('SELECT Uri FROM Orion.Groups WHERE ContainerId=1524')
          uri = x['results'][0]['Uri'] + '/CustomProperties'
          swis.update(uri, SITE_ADDRESS='13 Cherry Tree Ln.')
          

           

          Since SwisClient.update accepts a keyword dict, you can pass in your site_info dict to set all of those properties at once. You will need to remove the ContainerID property from the site_info, since that property is not updateable.