nerdexam
Cisco

300-835 · Question #23

Drag and drop the correct items from the right to complete this Python script to automate the creation of Cisco Webex Teams spaces and memberships. Not all options are used.

The options field in your question is empty ({}), so I can't explain the specific drag-and-drop items. Could you paste the actual option values? They likely include things like API endpoint URLs, HTTP method names, header keys, JSON payload keys, or specific Python library calls.

Cisco Webex API

Question

Drag and drop the correct items from the right to complete this Python script to automate the creation of Cisco Webex Teams spaces and memberships. Not all options are used.

Explanation

The options field in your question is empty ({}), so I can't explain the specific drag-and-drop items. Could you paste the actual option values? They likely include things like API endpoint URLs, HTTP method names, header keys, JSON payload keys, or specific Python library calls.

That said, here is the general framework for what this question is testing, so you know what to expect:


Goal: Automate Webex Teams via REST API in Python

Cisco Webex Teams exposes a REST API. The two core operations are:

  1. Create a Space (called a "room" in the API) - POST /rooms
  2. Add a Member to that space - POST /memberships

A correct Python script follows this pattern:

import requests

BASE_URL = "https://webexapis.com/v1"
TOKEN = "your_personal_access_token"

HEADERS = {
    "Authorization": f"Bearer {TOKEN}",
    "Content-Type": "application/json"
}

# Step 1: Create the space
room_payload = {"title": "My New Space"}
response = requests.post(f"{BASE_URL}/rooms", headers=HEADERS, json=room_payload)
room_id = response.json()["id"]

# Step 2: Add a member to the space
member_payload = {
    "roomId": room_id,
    "personEmail": "[email protected]"
}
requests.post(f"{BASE_URL}/memberships", headers=HEADERS, json=member_payload)

Step-by-Step Reasoning

1. Set the Authorization Header with a Bearer Token

The Webex API requires every request to carry a Personal Access Token or bot token. Without "Authorization": f"Bearer {TOKEN}", every request returns 401 Unauthorized.

2. POST to /rooms to create the space

You must create the space first because you need the roomId it returns. The roomId is the foreign key required in the membership request. Skipping this means you have no room to add members to.

3. Extract room_id from the response JSON

The response body contains the newly created room's metadata. You must parse response.json()["id"] to get the roomId. Using the wrong key (e.g., "roomId" instead of "id") returns KeyError and breaks step 4.

4. POST to /memberships using that roomId

This links a user (by personEmail or personId) to the room. This must come after step 2 - if you POST to /memberships before the room exists, the API returns a 404 or 400 error.


What Goes Wrong If Steps Are Out of Order

MistakeResult
No auth header401 Unauthorized on every call
POST /memberships before /roomsroomId is undefined - NameError or API 400
Wrong JSON key for room IDKeyError - script crashes before membership call
Missing Content-Type: application/jsonAPI may reject the body with 400

Memory Tip

"Header → Room → ID → Member" - you always authenticate first, create the container, capture its ID, then add people to it. It's the same mental model as: get a key, unlock a room, then invite guests.


Please share the actual option list and I can map each item precisely to the correct slot in the script.

Topics

#Webex API#Python scripting#Teams spaces#API integration

Community Discussion

No community discussion yet for this question.

Full 300-835 Practice