nerdexam
Cisco

300-435 · Question #135

Fill in the blanks in the provided Python code snippet to correctly make an API request for creating a new network. ``python Org_ID = "54523C" Net_ID = "L-646029496481107644" base_URL =…

This question tests knowledge of the Cisco Meraki Dashboard API v0 - specifically how to correctly construct a POST request to create a new network, including proper URL formatting, request body fields, and HTTP method selection.

Controller-Based Network Automation

Question

Fill in the blanks in the provided Python code snippet to correctly make an API request for creating a new network.
Org_ID = "54523C"
Net_ID = "L-646029496481107644"
base_URL = "https://api.meraki.com/api/v0"
api_URL = "api/v0/organizations/L-646029496481107644"
url = f"{base_URL} organizations/(Org_ID)/networks"
body = {
 "name": "Building-B2",
 "timezone": "America/New_York",
 " ": " ", "combined"
 "productTypes": [
 "wireless",
 "cameras"
 ]
}
headers = {
 "Accept": "application/json",
 "Content-Type": "application/json",
 "X-Cisco-Meraki-API-Key": API_KEY
}

response = requests.request(" ", url, headers=headers, json=body)
if response.status_code == 403:
 print(response.json(), indent=2))
else:
 print("Forbidden!")
Available options to fill the blanks (not all may be used): organizations/(Org_ID)/networks, combined, networks/(Net_ID)/network, POST, PUT, type, medium.

Explanation

This question tests knowledge of the Cisco Meraki Dashboard API v0 - specifically how to correctly construct a POST request to create a new network, including proper URL formatting, request body fields, and HTTP method selection.

Approach. Three blanks must be filled. (1) The request body needs '"type": "combined"' - in Meraki API v0, 'type' is the field that specifies the network type, and 'combined' means the network supports multiple product types (wireless + cameras together). (2) The HTTP method in requests.request() must be 'POST' because creating a new resource follows REST convention: POST to a collection endpoint (/organizations/{Org_ID}/networks) creates a new member. (3) The url f-string is malformed as written - the correct construction is f"{base_URL}/organizations/{Org_ID}/networks", using curly braces around variable names for interpolation. Note also that the if/else logic at the bottom is inverted: status 403 IS the Forbidden error, so 'Forbidden!' should print inside the if-block, not the else.

Concept tested. Cisco Meraki REST API v0 - constructing a network creation request: correct HTTP verb (POST vs PUT), proper f-string URL interpolation with Org_ID, required body fields ('type': 'combined' for multi-product networks), and status code interpretation (403 = Forbidden).

Reference. Cisco Meraki Dashboard API v0 - POST /organizations/{organizationId}/networks endpoint documentation.

Topics

#Meraki API#REST API#Python requests#Network Creation

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice