nerdexam
Cisco

300-435 · Question #114

Refer to the exhibit. An engineer must create a network Fabric using the Cisco Catalyst Center (formerly DNA Center) API. Which line of code completes the code snippet? ``python import requests from…

The correct answer is C. sda_fabric_info = {"fabricName": "DNAC_Guide_Fabric"}. To create an SDA Fabric using the Cisco Catalyst Center API, the payload for the POST request must be a JSON object containing a fabricName key with the desired fabric name.

Controller-Based Network Automation

Question

Refer to the exhibit. An engineer must create a network Fabric using the Cisco Catalyst Center (formerly DNA Center) API. Which line of code completes the code snippet?
import requests
from requests.auth import HTTPBasicAuth
import urllib3

BASE_URL = 'https://<CIP Address>'
AUTH_URL = '/dna/system/api/v1/auth/token'
USERNAME = '<USERNAME>'
PASSWORD = '<PASSWORD>'

response = requests.post(BASE_URL + AUTH_URL, auth=HTTPBasicAuth(USERNAME, PASSWORD), verify=False)
token = response.json()['Token']
headers = {'Content-Type': 'application/json', 'X-Auth-Token': token}
SDA_FABRIC_URL = '/dna/intent/api/v1/business/sda/fabric'

# MISSING LINE HERE

response = requests.post(BASE_URL + SDA_FABRIC_URL, headers=headers, json=sda_fabric_info, verify=False)

Exhibits

300-435 question #114 exhibit 1
300-435 question #114 exhibit 2

Options

  • Asda_fabric_info = {"fabricName":"DNAC_Guide_Fabric"}
  • Bsda_fabric_info = {"DNAC_Guide_Fabric"}
  • Csda_fabric_info = {"fabricName": "DNAC_Guide_Fabric"}
  • Dsda_fabric_info = {"fabricName": "DNAC_Guide_Fabric"}

How the community answered

(43 responses)
  • A
    2% (1)
  • C
    95% (41)
  • D
    2% (1)

Why each option

To create an SDA Fabric using the Cisco Catalyst Center API, the payload for the POST request must be a JSON object containing a `fabricName` key with the desired fabric name.

Asda_fabric_info = {"fabricName":"DNAC_Guide_Fabric"}

This choice uses double curly braces for the outer dictionary, which would lead to a syntax error in Python; dictionaries are defined with single curly braces.

Bsda_fabric_info = {"DNAC_Guide_Fabric"}

This choice provides a list containing a single string, not a dictionary with a key-value pair as required for the API payload.

Csda_fabric_info = {"fabricName": "DNAC_Guide_Fabric"}Correct

The line `sda_fabric_info = {{"fabricName": "DNAC_Guide_Fabric"}}` correctly assigns a Python dictionary to the `sda_fabric_info` variable, which will be serialized as a JSON object in the `requests.post` call. The dictionary includes the mandatory `fabricName` key with its corresponding string value, matching the expected payload structure for creating an SDA Fabric via the Cisco Catalyst Center API.

Dsda_fabric_info = {"fabricName": "DNAC_Guide_Fabric"}

This choice is syntactically identical to option C and would also be correct, but typically only one choice is the intended answer in a multiple-choice question format.

Concept tested: Cisco Catalyst Center API - SDA Fabric creation payload

Source: https://developer.cisco.com/docs/dna-center/#!create-fabric

Topics

#Cisco Catalyst Center API#REST API#Python requests#JSON payload

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice