9 Replies Latest reply on Aug 1, 2017 10:05 AM by c.gura

    SWIS Fails when querying uninitialized Date/Time fields in NodesCustomProperties

    steph@ethericnetworks.com

      I've run into a strangeness dealing with SWQL/SWIS.  If I use the following query in SWQL Studio, it works fine.  If I attempt to run the same query via SWIS (python flavor), I get a strange error.

       

      I created a (Node) Custom Property called SLA_Sync_Time which is defined as a Date/Time custom property: not required, no default value.

       

      Here's the (simple/sample) query:

           SELECT TOP 10 NodeID, SLA_Sync_Time from Orion.NodesCustomProperties

       

      When I run this in SWQL Studio, I get the 10 rows I would expect.

       

      The python code looks like so:

      import requests

      import orionsdk

       

      npm_server = '<server>'

      npm_user = '<user>'

      npm_password = '<password>'

      requests.packages.urllib3.disable_warnings()

      swis = orionsdk.SwisClient(npm_server, npm_user, npm_password)

       

      sql = "SELECT TOP 10 NodeID, SLA_Sync_Time from Orion.NodesCustomProperties"

      print swis.query(sql)['results']

       

      This produces the following error:

            requests.exceptions.HTTPError: 400 Client Error: Cannot set Column 'SLA_Sync_Time' to be null. Please use DBNull instead.

       

      This is weird in that (a) I'm not trying to 'set' anything (so the message is particularly scary) and (b) it works in SWQL.

       

      I have a few of these Date/Time properties, and all of them generate the same error.

       

      What's the best work-around?  Set a default date (I'd rather not, as that puts bogus data in my DB)?  Update all of the fields to contain a DBNull (how)?