200-901 · Question #288
Drag and Drop Questions Refer to the exhibit. A developer is creating a Python script to obtain a list of HTTP servers on a network named office_east by using the Cisco Meraki API. The request has the
The correct answer is response; 2; cert; HTTPBasicAuth. This question tests the ability to correctly construct a Python HTTP request using the requests library, incorporating requirements for response assignment, timeout, client certificates, SSL verification, and basic authentication.
Question
Drag and Drop Questions Refer to the exhibit. A developer is creating a Python script to obtain a list of HTTP servers on a network named office_east by using the Cisco Meraki API. The request has these requirements:
- Must time out if the response is not received within 2 seconds.
- Must utilize client certificates and SSL certificate verification.
- Must utilize basic authentication that uses a username of admin and a
password of cisco.
- Must save the response to an object named response.
Drag and drop the code snippets from the bottom onto the blanks in the code to meet the requirements. Not all options are used. Answer:
Exhibit
Answer Area
Drag items
Correct arrangement
- response
- 2
- cert
- HTTPBasicAuth
Explanation
This question tests the ability to correctly construct a Python HTTP request using the requests library, incorporating requirements for response assignment, timeout, client certificates, SSL verification, and basic authentication.
Approach. The correct interaction involves dragging the appropriate code snippets into the designated blanks to meet the specified requirements:
response: The first blank is for assigning the result of therequests.get()call. The requirement 'Must save the response to an object named response' directly maps to placingresponsehere.2: The second blank is for thetimeoutparameter. The requirement 'Must time out if the response is not received within 2 seconds' dictates that the value should be2.cert: The third blank precedes the tuple('/etc/pki/tls/certs/client.pem', '/etc/pki/tls/certs/client.key'). This tuple represents the client certificate and key for mutual TLS authentication. Therequestslibrary uses thecertparameter for this purpose. The requirement 'Must utilize client certificates' confirms this choice.HTTPBasicAuth: The fourth blank is for theauthparameter, followed by('admin', 'cisco'). The requirement 'Must utilize basic authentication that uses a username of admin and a password of cisco' and the prior importfrom requests.auth import HTTPBasicAuthindicate thatHTTPBasicAuthis the correct class to instantiate for basic authentication.
Common mistakes.
- common_mistake. Common mistakes include:
- Using
HTTPTokenAuthinstead ofHTTPBasicAuth: The question explicitly states 'basic authentication' and provides a username/password, which are hallmarks of basic authentication, not token-based.HTTPTokenAuthis used when an API token is provided. - Confusing
certwith other parameters or omitting it: Thecertparameter is specifically for client-side certificate authentication (mutual TLS), distinct fromverify, which is for validating the server's SSL certificate. Forgettingcertwould violate the client certificate requirement. - Incorrectly assigning
tokenor other unrelated snippets:tokenis not relevant for basic authentication or the response object assignment in this context. - Incorrect timeout value: Entering a value other than
2would fail the timeout requirement.
Concept tested. This question primarily tests the understanding and practical application of the Python requests library for making HTTP API calls, specifically focusing on advanced request parameters such as timeouts, client-side certificate authentication (mutual TLS), server-side SSL certificate verification, and different types of HTTP authentication (basic authentication). It also implicitly tests the ability to interpret API documentation and scenario requirements.
Topics
Community Discussion
No community discussion yet for this question.
