nerdexam
Cisco

300-435 · Question #138

Refer to the exhibit. A network engineer developed a script to automate the method to retrieve a list of network devices that are deployed to an enterprise. When the script is executed, it fails to re

Sign in or unlock 300-435 to reveal the answer and full explanation for question #138. The question stem and answer options stay visible for context.

Network Automation Foundation

Question

Refer to the exhibit. A network engineer developed a script to automate the method to retrieve a list of network devices that are deployed to an enterprise. When the script is executed, it fails to retrieve the list of devices. Which action resolve the issue?
1 def network_device_list(apic, ticket, id=None):
2
3 # Use the REST API to retrieve the list of network devices.
4 # If a device id is provided, return only that device
5
6 url = "https://{}/api/v1/network-device".format(apic)
7 headers = {"X-auth-token": " " + ticket}
8
9 # Change URL to single device given an id
10 if id:
11 url += "/{}".format(id)
12
13 # Make API request and return the response body
14 response = requests.request("PUT", url, headers=headers, verify=False)
15
16 # Always return a list object, even if single device for consistency
17 if id:
18 return [response.json()] ["response"]
19
20 return response.json() ["response"]

Exhibit

300-435 question #138 exhibit

Options

  • AChange PUT to GET.
  • BChange PUT to DELETE.
  • CChange PUT to POST.
  • DChange PUT to PATCH.

Unlock 300-435 to see the answer

You've previewed enough free 300-435 questions. Unlock 300-435 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#REST API#HTTP methods#Python requests#API troubleshooting
Full 300-435 Practice