11-04-2020 08:55 PM
I wasnt able to download directly from github but I am doing this lab...
can do this with postman but having issues with python
I had to copy and paste the script into sublime text and save as python file.
I made a new folder on my desktop and added the path to system path
when I try to do from dnac import ....
I get this ...
>>> from dnac_config import DNAC
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'dnac_config'
any info is appreciated
11-05-2020 02:28 AM
Thanks for noting this, i see a mistake in the learning lab - i have opened this support request with the team to look at this https://github.com/CiscoDevNet/learning-labs-issues/issues/278
Please use the following
import requests from requests.auth import HTTPBasicAuth from dnac_config import DNAC_IP, USERNAME, PASSWORD requests.packages.urllib3.disable_warnings() def get_auth_token(): url = 'https://sandboxdnac.cisco.com/dna/system/api/v1/auth/token' resp = requests.post(url, auth=HTTPBasicAuth(USERNAME, PASSWORD), verify=False) token = resp.json()['Token'] print("Token Retrieved: {}".format(token)) return token if __name__ == "__main__": get_auth_token()
09-14-2021 07:33 AM
SyntaxError: invalid syntax
PS C:\Users\cbqz9250> & python c:/Users/cbqz9250/CloudDrive/Documents/Python/Code/testtoken.py
Traceback (most recent call last):
File "c:\Users\cbqz9250\CloudDrive\Documents\Python\Code\testtoken.py", line 3, in <module>
from dnac_config import DNAC_IP, USERNAME, PASSWORD
ModuleNotFoundError: No module named 'dnac_config'
PS C:\Users\cbqz9250>
Still getting same error -->
Code -->
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