nerdexam
Cisco

200-901 · Question #56

FILL BLANK Fill in the blanks to complete the Python script to retrieve a list of network devices using the Cisco DNA Center API. my_token= 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzl1NiJ9.ey.JzdWloOil1ZDE0OWZkM

The correct answer is A. "GET", url, headers = headers, data = payload. The Python requests library requires the HTTP method, URL, headers, and data payload as arguments to requests.request(), and a GET call with the x-auth-token header is the correct way to retrieve network devices from the Cisco DNA Center API.

Understanding and Using APIs

Question

FILL BLANK Fill in the blanks to complete the Python script to retrieve a list of network devices using the Cisco DNA Center API. my_token= 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzl1NiJ9.ey.JzdWloOil1ZDE0OWZkMjhlZTY2 MmQ3NGM5YzE5ZTliLmYzMCLslmV4CcCI6MTU3MjM3ODE%MCwidXNlcm5hbWUiOiJraX N370940885.zhK5LPQd501ZUpZI0IH_qrgOXttlNbxSFFF7JOEtRls' import requests url = "https://myDNAserver/dna/intent/api/v1/network-device" payload = {} headers = {'x-auth-token': my_token} } response = requests.request( _______________________ , url, headers = _________________________, data = _______________________ ) print(response.text.encode('utf8')) Answer: See explanation below.

Options

  • A"GET", url, headers = headers, data = payload

How the community answered

(21 responses)
  • A
    100% (21)

Why each option

The Python requests library requires the HTTP method, URL, headers, and data payload as arguments to requests.request(), and a GET call with the x-auth-token header is the correct way to retrieve network devices from the Cisco DNA Center API.

A"GET", url, headers = headers, data = payloadCorrect

The requests.request() function signature requires the method as the first positional argument ("GET" for a read operation), followed by the URL, then keyword arguments for headers and data. Using headers=headers passes the dictionary containing the 'x-auth-token' JWT for authentication, and data=payload passes the empty payload dict, which is correct for a GET request to the Cisco DNA Center network-device endpoint.

Concept tested: Cisco DNA Center REST API call using Python requests

Source: https://developer.cisco.com/docs/dna-center/#!cisco-dna-center-platform-overview

Topics

#Python requests#REST API#HTTP GET method#Cisco DNA Center

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice