nerdexam
CiscoCisco

200-901 · Question #82

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

A Python script creating a Meraki network using the API requires filling in the correct HTTP method, API endpoint segments, authentication header, content type, and request body parameters.

Cisco Platforms and Development

Question

Drag and Drop Question Refer to the exhibit. Drag and drop the code from the left onto the item numbers on the right to complete to Meraki python script shown in the exhibit. Answer:

Explanation

A Python script creating a Meraki network using the API requires filling in the correct HTTP method, API endpoint segments, authentication header, content type, and request body parameters.

Approach. To correctly complete the Python script, each placeholder must be filled based on the Meraki API documentation and standard requests library usage:

  • <item 1>: The API documentation specifies a POST request to create a new network. Therefore, post should be dragged here to call requests.post().
  • <item 2>: The URL construction starts with the base_url defined earlier in the script. So, base_url is the correct choice.
  • <item 3>: Following the base_url and the first slash, the API path (from Exhibit 1) is /organizations/{organizationId}/networks. Thus, organizations precedes the org_id variable.
  • <item 4>: After the org_id and the subsequent slash, the path concludes with networks to target the network creation endpoint.
  • <item 5>: The X-Cisco-Meraki-API-Key header is for authentication and requires the API key, which is stored in the api_key variable.
  • <item 6>: When sending a JSON payload, the Content-Type header must be set to application/json.
  • <item 7>: The json.dumps() function is used to serialize a Python dictionary into a JSON string. When passing a pre-serialized JSON string to requests.post(), it should be assigned to the data parameter, not json (which is for Python dictionaries that requests will serialize itself).
  • <item 8>: The API documentation states that the 'name' parameter in the request body is for the network's name. The script defines network_name = 'New Network', so network_name is the correct variable.

Common mistakes.

  • common_mistake. Common mistakes would include using get instead of post for Item 1 (incorrect HTTP method for resource creation), mixing up the order of organizations and networks in the URL path (Items 3 and 4), using an incorrect variable for the API key (Item 5) or content type (Item 6), or incorrectly passing the JSON payload. For instance, if json were used for Item 7 instead of data, the requests library would attempt to serialize the already serialized JSON string again, potentially leading to malformed JSON or an error. Using org_id or api_key for Item 8 would incorrectly set the network name. These errors demonstrate a lack of understanding of REST API principles, Python's requests library, or specific Meraki API requirements.

Concept tested. REST API interaction using Python's requests library, including making POST requests, constructing API endpoint URLs, setting HTTP headers for authentication and content type, and handling JSON request bodies. It also tests understanding of specific Meraki API conventions for creating network resources.

Topics

#Python Scripting#Meraki API#Network Automation#API Interaction

Community Discussion

No community discussion yet for this question.

Full 200-901 PracticeBrowse All 200-901 Questions