nerdexam
Cisco

200-901 · Question #72

FILL BLANK Fill in the blanks to complete the Python script to request a service ticket using the APIC-EM REST API for the user "devnetuser". import requests import json controller =…

The correct answer is A. devnetuser, requests, header. The script requires 'devnetuser' as the username string, 'requests' as the HTTP library, and 'header' as the headers variable to complete the APIC-EM service ticket POST request.

Understanding and Using APIs

Question

FILL BLANK Fill in the blanks to complete the Python script to request a service ticket using the APIC-EM REST API for the user "devnetuser". 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) Answer: See explanation below

Options

  • Adevnetuser, requests, header

How the community answered

(41 responses)
  • A
    100% (41)

Why each option

The script requires 'devnetuser' as the username string, 'requests' as the HTTP library, and 'header' as the headers variable to complete the APIC-EM service ticket POST request.

Adevnetuser, requests, headerCorrect

The first blank is 'devnetuser', matching the username specified in the question and used as the credential in the payload dictionary. The second blank is 'requests', the imported HTTP library whose .post() method sends the API call. The third blank is 'header', the variable defined earlier in the script holding the Content-type dictionary passed to the headers argument.

Concept tested: Python requests library usage for APIC-EM REST API authentication

Source: https://developer.cisco.com/docs/apic-em/

Topics

#Python scripting#REST API#requests library#API authentication

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice