300-435 · Question #130
300-435 Question #130: Real Exam Question with Answer & Explanation
The correct interaction involves selecting the POST request snippet that includes both headers and data=payload, as it represents a complete and robust API call for potentially complex monitoring queries in vManage, despite the function name suggesting a GET operation.
Question
Drag and drop the code snippets from the bottom onto the boxes in the code to complete the retrieve_interfaces_info function that captures information about IPv4 interfaces on a device using vManage Monitoring API. Not all options are used.
Explanation
The correct interaction involves selecting the POST request snippet that includes both headers and data=payload, as it represents a complete and robust API call for potentially complex monitoring queries in vManage, despite the function name suggesting a GET operation.
Approach. The correct interaction is to drag and drop the snippet response = requests.request('POST', url, headers=headers, data=payload) into the appropriate placeholder in the retrieve_interfaces_info function. The reasoning is twofold: First, while the function name retrieve_interfaces_info typically implies a GET request for retrieving information, none of the provided snippets offer a GET option. However, the vManage API endpoint list shows numerous POST endpoints (e.g., /device/tools/ping, /device/tools/traceroute) that trigger actions and then return information. This pattern suggests that the vManage API may use POST for complex monitoring queries or to initiate reporting that yields the desired interface information, especially if query parameters are included in the request body. Second, for an enterprise API interaction like vManage, a POST request that sends data (payload) almost always requires headers (for authentication, content-type, etc.) to ensure the request is properly authenticated and processed. Therefore, the snippet that includes both headers=headers and data=payload is the most complete and robust choice, adhering to best practices for secure and functional API communication.
Common mistakes.
- common_mistake. Common mistakes include selecting a
DELETErequest snippet, which is fundamentally incorrect asDELETEis used for resource removal, not information retrieval. Another mistake is choosing thePOSTsnippet that omitsheaders=headers(response = requests.request('POST', url, data=payload)). While it uses thePOSTmethod and sends a payload, most enterprise APIs like vManage require specific headers (e.g., Authorization, Content-Type) for successful authentication and correct data processing. Omitting these headers would likely result in an authentication failure or an incorrectly processed request, rendering it incomplete and non-functional in a real-world scenario.
Concept tested. This question tests the understanding of HTTP methods (POST, GET, DELETE) and their appropriate use in RESTful API interactions, proficiency with the Python requests library for making API calls, and knowledge of essential API request parameters such as url, headers, and data (payload). It also implicitly assesses the ability to infer API behavior (e.g., using POST for complex queries yielding information) when standard options are not directly available, based on observed API patterns.
Topics
Community Discussion
No community discussion yet for this question.