nerdexam
CiscoCisco

200-901 · Question #426

200-901 Question #426: Real Exam Question with Answer & Explanation

This question tests the ability to construct a REST API request in Python by correctly identifying the HTTP method, URL components, request body parameters, and authentication headers from API documentation.

Infrastructure and Automation

Question

Drag and Drop Question Refer to the exhibit. Drag and drop the code from the bottom onto the box where the code is missing to construct an API request that creates a new IPv4 prefix. Not all options are used. Answer:

Explanation

This question tests the ability to construct a REST API request in Python by correctly identifying the HTTP method, URL components, request body parameters, and authentication headers from API documentation.

Approach. To correctly complete the Python code, the test-taker must refer to the API documentation and understand common REST API patterns:

  1. First blank (url = f'{ }'/object/ipv4prefixlists'): The url variable is being constructed using an f-string. The BASE_URL variable is defined as 'https://ftd.example.com/api/fdm/latest'. This is the base part of the API endpoint. Dragging BASE_URL completes the URL string correctly.
  2. Second blank ('type': ' ' within the entries list): The API documentation specifies that the type parameter (both for the main object and, by inference, for individual entries within the entries array) should represent the 'class-type' and correspond to the 'class name'. Given that the resource is an 'IPv4 Prefix List', ipv4prefixlist is the appropriate class name. Dragging ipv4prefixlist ensures the entry's type is correctly defined.
  3. Third blank ('Authorization': f'Bearer { }'): This is a standard authorization header. The value after 'Bearer ' is typically an access token. The code snippet defines a variable token containing a sample bearer token. Dragging token correctly populates the authorization header.
  4. Fourth blank (response = requests.request(' ', url, ...)): The requests.request method requires the HTTP method as its first argument. The API documentation explicitly states that POST is the method for creating a new IPv4 prefix list. Dragging POST correctly specifies the HTTP operation.

Common mistakes.

  • common_mistake. Common mistakes include:
  • Dragging GET instead of POST: GET is used to retrieve data, whereas the documentation explicitly states POST for creating (new) resources. Using GET would result in an incorrect request.
  • Dragging URL instead of BASE_URL: The URL option is a generic term, but BASE_URL is the specific variable defined in the Python script that holds the base portion of the API endpoint, making it the correct choice for string concatenation in the f-string.
  • Dragging api_key instead of token: While api_key is a form of authentication, the header Authorization: f'Bearer { }' specifically indicates a Bearer token authentication scheme. A token variable is explicitly defined in the script for this purpose, making token the precise and correct fit.
  • Misinterpreting the type field or using an incorrect value: Some might attempt to use URL or api_key here, but the context clearly indicates a string representing the resource's class name, which is ipv4prefixlist based on the resource being managed.

Concept tested. This question tests the understanding of REST API request construction, including HTTP methods (POST), URL structure (base URL, endpoint path), request body (payload) composition, JSON data formatting, and authentication mechanisms (Bearer token) within the context of a Python requests library script. It also assesses the ability to interpret and apply information from API documentation.

Topics

#API Request Construction#HTTP POST Method#RESTful APIs#Network Automation

Community Discussion

No community discussion yet for this question.

Full 200-901 PracticeBrowse All 200-901 Questions