orionsdk-python: 400 Client Error: Specified cast is not valid
Hi Guys,
Im getting the following error when trying use the Python class to add a node to NPM that uses SNMPv3;
[mw@ansible-001 orion]$ python add_node.py
Add an SNMP v3 node:
/usr/lib/python2.7/site-packages/requests/packages/urllib3/connection.py:340: SubjectAltNameWarning: Certificate for solarwinds-orion has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
SubjectAltNameWarning
Adding node 10.116.26.80... Traceback (most recent call last):
File "add_node.py", line 138, in <module>
main()
File "add_node.py", line 96, in main
results = swis.create('Orion.Nodes', **Orion_Nodes)
File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 34, in create
"Create/" + entity, properties).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 909, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Specified cast is not valid. for url: https://solarwinds-orion:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Nodes
This is my python script, its just to get a feel for the NPM API and this Python class:
[me@ansible-001 orion]$ cat add_node.py
from __future__ import print_function
import re
import requests
from orionsdk import SwisClient
def main():
npm_server = 'SolarWinds-Orion'
username = 'sw-user'
password = 'sw-pass'
swis = SwisClient(npm_server, username, password, verify="SolarWinds-Orion.pem")
# Only need one of [DisplayName, Caption, NodeName]
Orion_Nodes = {
'DisplayName': "cpe",
'Description': "cpe",
'NodeDescription': "my cpe",
'Location': "Lab",
'UnManaged': False,
'Allow64BitCounters': True,
'ObjectSubType': "SNMP",
'EngineID': 1,
'IPAddress': "10.116.26.80",
'SNMPVersion': '3',
'SNMPV3Username': "snmpv3-user",
'SNMPV3PrivMethod': "AES128",
'SNMPV3PrivKeyIsPwd': True,
'SNMPV3PrivKey': "snmpv3-priv-key",
'SNMPV3AuthKey': "snmpv3-auth-key",
'SNMPV3AuthMethod': "MD5",
'SNMPV3AuthKeyIsPwd': True
}
print("Add an SNMP v3 node:")
print("Adding node {}... ".format(Orion_Nodes['IPAddress']), end="")
results = swis.create('Orion.Nodes', **Orion_Nodes)
print("DONE!")
if __name__ == '__main__':
main()
This node is actually added to SNMP however all the SNMPv3 details are missing, as per this screenshot:

This is on Orion Platform 2017.1, NPM 12.1, I’m using Python 2.7.5. I can add the device manually through the web GUI using SNMPv3 without issue. I can also add the device using SNMP v2c via the GUI and API. It is just SNMPv3 via the API that is not working.
I can open a support case on the SW site too if that helps?
Please let me know what further info I can provide to help diagnose this issue.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (10 by maintainers)
I opened internal bug and we will track it under CORE-8580. You can use that number to check on the fix status.
Unfortunately there is a bug in the product. Boolean JSON True/False parameters are not processed correctly for SNMPv3 configuration.
As workaround I would recommend trying PowerShell, for PowerShell it should work. You can find PS example for node creation here: https://github.com/solarwinds/OrionSDK/blob/master/Samples/PowerShell/CRUD.AddNode.ps1
Example of node properties: