cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
515
Views
0
Helpful
1
Replies

DNA API - Add Network-Device Troubleshooting

korey_oehlers
Level 1
Level 1

Hello,

 

I'm having trouble adding devices to DNA with the API.  I've read the documentation (Cisco DevNet: APIs, SDKs, Sandbox, and Community for Cisco Developers), but can't tell what's wrong. When I try my python method I get this non descript error:

'errorCode': 'Bad request', 'message': 'Invalid input request', 'detail': 'There was an error processing the input arguments.'

 

Is there anywhere I can look to find a better error message?  Here is my python method:

def add_dna_device(token, device):

    url = f'https://{server}/dna/intent/api/v1/network-device'

    headers = {
        "Content-Type": "application/json",
        "X-Auth-Token": f"{token}"
    }
   
    payload = {
        "type": "NETWORK_DEVICE",
        "cliTransport": "ssh2",
        "ipAddress": [ f"{device}" ],
        "snmpVersion": "2c",
        "snmpROCommunity": "test",
        "snmpRWCommunity": "test",
        "snmpRetry": 3,
        "snmpTimeout": 5,
        "userName": "test",
        "password": "test",
        "enablePassword": "test"
    }

    response = requests.post(url, headers=headers, data=payload, verify=False)

    return response.json()['response']
I've tried using more of the variables in the payload, but can't find a combination that works.
 
Thanks for your time!
1 Reply 1

Alexander Stevenson
Cisco Employee
Cisco Employee

Hi @korey_oehlers,

 

I  justing looking at your code in VS Code to debug. Is 'server' global or provided somewhere else in this file? It's not included in the parameters like 'token' and 'device' are. 

 

Other than that, it looks good to me.