06-30-2020 01:49 AM
Hello, I am trying to add a new device using the DNA sandbox but I keep getting a 403 response. Is there something wrong with my code?
07-06-2020 05:54 AM
07-06-2020 03:07 PM
I believe the IpAddress formatting is ok. If you use it differently, you get:
"Reason: data.ipAddress must be array or null"
07-06-2020 04:34 PM
This has worked for me. Excluding some code, but try adding some additional required fields in your payload as I think that is your issue. See below:
def add_device(IP_ADDR):
data = get_token()
print "***************************"
API_URL = 'https://<dnac>/dna/intent/api/v1/network-device/'
AUTH = {
'X-Auth-Token' : data,
'Content-type' : 'application/json'
}
NAD_OBJ ={
"ipAddress" :[
IP_ADDR
],
"type" : "NETWORK_DEVICE",
"computeDevice" : False,
"snmpVersion" : "V3",
"snmpUserName" : "<user>",
"snmpMode" : "RW",
"snmpAuthProtocol" : "SHA",
"snmpAuthPassphrase" : "<pass>",
"snmpPrivProtocol" : "AES128",
"snmpPrivPassphrase" : "<pass>",
"snmpRetry" : "3",
"snmpTimeout" : "5",
"cliTransport" : "SSH",
"userName" : "<youruser>",
"password" : "<yourpw>",
"enablePassword" : "<yourpw>",
}
r = requests.post(url=API_URL, headers=AUTH, verify=False, json=NAD_OBJ)
print r.text
print "SDA Device", r.reason
HTH!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide