2 Replies Latest reply on Feb 9, 2017 5:02 PM by mxr662

    Error adding custom property Python

    mxr662

      Getting an error when trying to pass more than 10 parameters with CreateCustomProperty.  This works with just 10 parameters.  Also CreateCustomPropertyWithValues gets an error with more than 11 parameters.  Trying to set mandatory and a default value.

       

      Andy

       

      Name: requests Version: 2.11.1

      Name: orionsdk Version: 0.0.6

      Python 2.7.5

      NPM 12.0.1

       

      Traceback (most recent call last):

        File "create-custom-property-ITResource-test.py", line 30, in <module>

          main()

        File "create-custom-property-ITResource-test.py", line 24, in main

          'null'

        File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 29, in invoke

          "Invoke/{}/{}".format(entity, verb), args).json()

        File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 59, in _req

          resp.raise_for_status()

        File "/usr/lib/python2.7/site-packages/requests/models.py", line 862, in raise_for_status

          raise HTTPError(http_error_msg, response=self)

      requests.exceptions.HTTPError: 400 Client Error: Verb Orion.NodesCustomProperties.CreateCustomProperty cannot unpackage parameter 10 with type System.Collections.Generic.Dictionary`2[System.String,System.Boolean] for url: https://10.96.254.85:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.NodesCustomProperties/CreateCustomProperty

       

       

      #from __future__ import print_function

      import re

      import requests

      import config

      from orionsdk import SwisClient

       

       

      def main():

              swis = SwisClient(config.npm_server, config.username, config.password)

              results = swis.invoke(

                  'Orion.NodesCustomProperties',

                  'CreateCustomProperty',

                  'ITResourceTest1',

                  'Excludes IT resources from  alarms if set to NO',

                  'string',

                  4000,

                  'null',

                  'null',

                  'null',

                  'null',

                  'null',

                  'null',

                  'null',

                  'true',

                  'null'

             )

       

      requests.packages.urllib3.disable_warnings()

       

      if __name__ == '__main__':

              main()

        • Re: Error adding custom property Python
          tdanner

          To pass null from Python, don't send 'null' (which is a 4-character string containing n, u, l, and l). Instead send None (with no quotes). This will get translated to JSON as null (again, no quotes) and should do what you want.

          1 of 1 people found this helpful
            • Re: Error adding custom property Python
              mxr662

              Thank you, that works great.  This is what I ended up with.

               

              def main():

                      t = [ "NO", "ITTSUNIX", "ITTSWINDOWS", "ITTSNETWORK" ]

                      print (t)

                      swis = SwisClient(config.npm_server, config.username, config.password)

                      results = swis.invoke(

                          'Orion.NodesCustomProperties',

                          'CreateCustomPropertyWithValues',

                          'ITResource',

                          'Excludes IT resources from Netcool alarms if set to NO',

                          'string',

                          4000,

                          None,

                          None,

                          None,

                          None,

                          None,

                          None,

                          [

                          "NO",

                          "ITTSUNIX",

                          "ITTSWINDOWS",

                          "ITTSNETWORK",

                          ],

                         None,

                         True,

                         "NO"

                     )