nerdexam
Cisco

200-901 · Question #417

Drag and Drop Question Drag and drop the code from the bottom onto the box where the code is missing to authenticate with the Cisco DNA Center REST API by using basic authentication. Then generate a t

The correct answer is auth/basic; post; USERNAME. This question tests the ability to correctly complete Python code for authenticating with the Cisco DNA Center REST API using basic authentication to obtain a token.

Understanding and Using APIs

Question

Drag and Drop Question Drag and drop the code from the bottom onto the box where the code is missing to authenticate with the Cisco DNA Center REST API by using basic authentication. Then generate a token for later use. Not all options are used. Answer:

Exhibit

200-901 question #417 exhibit

Answer Area

Drag items

auth/basic/auth/tokenpostgetUSERNAMETokenPASSWORD

Correct arrangement

  • auth/basic
  • post
  • USERNAME

Explanation

This question tests the ability to correctly complete Python code for authenticating with the Cisco DNA Center REST API using basic authentication to obtain a token.

Approach. The correct interaction involves dragging and dropping the appropriate options into the four blank fields in the Python code:

  1. First blank (after AUTH_URL = '/dna/system/api/v1/'): Drag /auth/token here. This is the specific REST API endpoint used by Cisco DNA Center to generate an authentication token.
  2. Second blank (after response = requests.): Drag post here. Token generation, which involves creating a new session or credential, is typically done using the HTTP POST method.
  3. Third blank (inside auth=HTTPBasicAuth( before the comma): Drag USERNAME here. The HTTPBasicAuth constructor from the requests.auth module takes the username as its first argument.
  4. Fourth blank (inside auth=HTTPBasicAuth(USERNAME, after the comma): Drag PASSWORD here. The HTTPBasicAuth constructor takes the password as its second argument.

This sequence correctly constructs the API call to perform basic authentication and retrieve a token from the Cisco DNA Center.

Common mistakes.

  • common_mistake. Common mistakes include using incorrect HTTP methods or API endpoints, or misplacing the authentication credentials.
  • 'get' instead of 'post': Using 'get' is incorrect because obtaining a token involves creating a new session, which requires the POST method, not the GET method used for retrieving data.
  • 'auth/basic' instead of '/auth/token': 'auth/basic' is not the correct API endpoint for token generation; it might describe the type of authentication but not the specific resource path. The Cisco DNA Center API uses '/auth/token' to issue tokens.
  • 'Token' instead of 'USERNAME' or 'PASSWORD': 'Token' is a key in the expected JSON response, not a variable holding authentication credentials. Placing 'Token' in the HTTPBasicAuth constructor would result in incorrect authentication arguments or a 'NameError' if 'Token' were not defined as a variable.

Concept tested. This question primarily tests knowledge of Python's requests library for making HTTP requests, understanding of REST API authentication (specifically HTTP Basic Authentication), and the common API endpoints and methods used for token generation, particularly in the context of Cisco DNA Center.

Topics

#REST API Authentication#Basic Authentication#Token Generation#Cisco DNA Center API

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice