cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
739
Views
0
Helpful
3
Replies

Connecting to DNA Sandbox API results in http error code 500

cano707
Level 1
Level 1

Hello,

i am trying to connect to the DNA Sandbox with following script:

import http.client

conn = http.client.HTTPSConnection("sandboxdnac.cisco.com")

headers = {
    'content-type': "application/json",
    'authorization': "<Authorization>"
    }

conn.request("POST", "/dna/system/api/v1/auth/token", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Running this results in "Http Error Code 500" - an internal server side error.

Is there a way to resolve this issue?

 

Thank you!

3 Replies 3

Alex Stevenson
Cisco Employee
Cisco Employee

 

Hello @cano707,

 

 

I've found 2 discussions on these boards related to your issue:

 

 

 

I would also check your hard-coded values for variables and clear your browser cache. 

 

Thank you very much for your answer! Unfortunately, no solution was mentioned to my problem.

 

Because i was in hurry, i forgot to mention something important.

 

First:

    I copied the script from the API Documentation on the Sandbox Page

Second:

    I am able to run the API calls from within the API Documentation Page (Tools > Developer Toolkit).

    Pressing "Try It" gives me the result i would expect.

 

I just don't understand why the queries from my local computer are not working.

cano707
Level 1
Level 1

Alright, i don't know if this is intended but i somehow found a workaround.

 

In case that you are not able to get the 'token' via Python, you have to get ON the page

of the Sandbox API.

 

Follow these steps:

  1. Go to the Cisco DNA Center Platform (https://sandboxdnac.cisco.com/dna/home)
  2. Go to Platform > Developer Toolkit
  3. Click on Authentication API
  4. Click on Try It and follow the steps

After all that you will get a token, which you must store somewhere in your script.

Then you can use this token to make further API Calls.