Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Cisco Certified DevNet Associate (DEVASC) · Cisco
Hotspot Scenario
Select the appropriate option to complete the statement. Click Check Answer below to see the marked solution.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
Readable format with blanks: import requests import json controller = 'devnetapi.cisco.com/sandbox/apic_em' url = https:// + controller + api/va/ticket payload = {'username': '_________', 'password': '370940885'} header = {'Content-type': 'application/json'} response = _________.post(url, data=json.dumps(payload), headers=_________, verify=False) r_json = response.json() print(r_json) ticket = r_json[response][serviceTicket] print(ticket)
import requests import json controller = 'devnetapi.cisco.com/sandbox/apic_em' url = https:// + controller + api/va/ticket payload = {'username': 'devnetuser', 'password': '370940885'} header = {'Content-type': 'application/json'} response = requests.post(url, data=json.dumps(payload), headers=header, verify=False) r_json = response.json() print(r_json) ticket = r_json[response][serviceTicket] print(ticket) This script uses the requests library to make a POST request to the APIC-EM REST API to request a service ticket for the user devnetuser. The payload of the request includes the user's username and password, and the headers include the content-type as 'application/json'. The script also includes a verify=False to avoid any SSL certificate verification. The response is in json format and the script parse it to get the service ticket. The ticket is then printed.
import requests import json controller = ‘devnetapi.cisco.com/sandbox/apic_em’ url = “https://” + controller + “api/va/ticket” payload = {‘username’: ‘ ’, ‘password’: ‘370940885’} header = {‘Content-type’: ‘application.json’} response = .post(url, data=json.dumps(payload), \ headers= , verify=False) r_json = response.json() print(r_json) ticket = r_json[“response”][“serviceTicket”] print(ticket) Correct Answer: See explanation below Section: (none) devnetuser requests header https://developer.cisco.com/docs/apic-em/#!hello-world/issuing-requests-in-the-postman-gui