Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Cisco Certified DevNet Associate (DEVASC) · Cisco
Select one answer.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
The error 401 (Unauthorized) means that the authentication is failing. Looking at the script, the likely issue is that the authentication token is not included in the request headers when calling the network-device endpoint. Correct Answer: ✔ C. Send the Authentication header in the request with a valid configuration. Explanation: • The script correctly obtains an authentication token by sending a POST request to /dna/system/api/v1/auth/token. • However, after retrieving the token, the script does not include it in the headers for the GET request to /dna/intent/api/v1/network-device. • The Cisco DNA Center API requires an authentication token in the Authorization header for further API requests.
In the provided code, the authentication token is being requested and stored in the "token" variable, but it is not being included in the subsequent request for the device list. To solve the problem, the authentication token should be included in the request header as an "Authorization" field. For example: headers = {'Content-Type': 'application/json', 'Authorization': f'Bearer {token}'} This will include the necessary credentials in the request and allow it to be authenticated by the server.
what if the error occurred on the request.post when getting the token due to incorrect credentials? how would we know if the error is due to the incorrect credentials or incorrect syntax due to header of the request.get doesn't contain the token/data?