300-835 · Question #55
Drag and drop the code snippets from the bottom onto the boxes in the Python script to change the configured default volume of a device using the xAPI. Not all options are used.
The options field in your question came through empty ({}), so I don't have the actual code snippets to map to the blanks. That said, here is a thorough explanation of the concept and typical structure of this type of question, which should help you reason through it when you hav
Question
Explanation
The options field in your question came through empty ({}), so I don't have the actual code snippets to map to the blanks.
That said, here is a thorough explanation of the concept and typical structure of this type of question, which should help you reason through it when you have the options in front of you.
Overall Goal
The xAPI (Cisco's eXtensible API) lets you programmatically control Cisco collaboration endpoints (e.g., Webex Room devices) over HTTP. The goal here is to write a Python script that authenticates with a device and sends a configuration command to set its default audio volume.
Typical Script Structure and Reasoning
1. Import libraries
import requests
requests.packages.urllib3.disable_warnings()
Why: requests handles HTTP communication. Disabling warnings suppresses SSL certificate errors common on self-signed device certs. Skipping this causes noisy warnings or crashes depending on strictness.
2. Define connection parameters
ip = "192.168.1.1"
auth = ("admin", "password")
Why: The device IP and credentials are required for every API call. Without them the request has nowhere to go and no way to authenticate.
3. Set the correct headers
headers = {"Content-Type": "text/xml"}
Why: The xAPI expects XML-formatted payloads. The wrong Content-Type causes the device to reject the body.
4. Build the XML payload
payload = "<Configuration><Audio><DefaultVolume>50</DefaultVolume></Audio></Configuration>"
Why: This is the actual instruction. The xAPI uses a hierarchical XML structure mirroring the device's command tree. The wrong node path silently applies nothing or returns an error.
5. Send the request
response = requests.put(
f"https://{ip}/putxml",
auth=auth,
headers=headers,
data=payload,
verify=False
)
Why: PUT (or POST) to /putxml is the standard xAPI endpoint for configuration changes. verify=False bypasses SSL cert validation for self-signed certs.
6. Check the response
print(response.status_code)
Why: A 200 confirms success. Any other code indicates authentication failure, wrong endpoint, or malformed XML.
What Goes Wrong If Steps Are Out of Order
| Skipped Step | Result |
|---|---|
| No headers | Device rejects payload (400 or ignored) |
No auth | 401 Unauthorized |
| Wrong XML path | Command silently fails or 400 error |
No verify=False | SSL handshake error on self-signed certs |
Memory Tip
Think CASH: Connect (IP/auth), Assemble payload (XML), Send (PUT to /putxml), Handle response (check status code).
If you paste the actual code snippet options here, I can map them precisely to each blank.
Topics
Community Discussion
No community discussion yet for this question.