nerdexam
Cisco

300-835 · Question #21

Drag and Drop Question. Refer to the exhibit. A developer has implemented ChatOps to a Webex Teams space as described in the exhibit. The Python script that pushes the notifications to the Teams…

Issue: Missing Exhibit and Code Options The question is incomplete - the exhibit (describing the ChatOps setup) and the drag-and-drop code options are both missing. The Options: {} field is empty, so I cannot identify the specific blanks to fill. That said, here is a thorough…

Cisco Webex API

Question

Drag and Drop Question. Refer to the exhibit. A developer has implemented ChatOps to a Webex Teams space as described in the exhibit. The Python script that pushes the notifications to the Teams space is shown. Drag and drop the code to complete the script. Not all options are used.

Explanation

Issue: Missing Exhibit and Code Options

The question is incomplete - the exhibit (describing the ChatOps setup) and the drag-and-drop code options are both missing. The Options: {} field is empty, so I cannot identify the specific blanks to fill.

That said, here is a thorough explanation of the concept and correct approach for this type of question, which appears on Cisco DevNet exams (DEVASC 200-901).


Overall Goal

Send automated notifications to a Cisco Webex Teams space from a Python script using the Webex REST API. This is the canonical ChatOps pattern: an application event triggers a bot message into a collaboration space.


Why This Approach Is Correct

Webex Teams exposes a REST API at https://webexapis.com/v1/. Posting a message requires:

  1. A Bot token for authentication
  2. The target Room ID
  3. A POST to /messages with a JSON body

Python's requests library is the standard tool for this.


Typical Script Structure

import requests
import json

ACCESS_TOKEN = "your_bot_token_here"
ROOM_ID = "your_room_id_here"

url = "https://webexapis.com/v1/messages"

headers = {
    "Authorization": "Bearer " + ACCESS_TOKEN,
    "Content-Type": "application/json"
}

payload = {
    "roomId": ROOM_ID,
    "text": "Build pipeline passed successfully!"
}

response = requests.post(url, headers=headers, json=payload)
print(response.status_code)

Step-by-Step Reasoning

1. import requests / import json Required to make HTTP calls and serialize data. Skipping this causes a NameError at runtime.

2. Set ACCESS_TOKEN and ROOM_ID The bot must authenticate and know where to post. Without ACCESS_TOKEN, the API returns 401 Unauthorized. Without ROOM_ID, there is no target.

3. Build the headers dict with Authorization: Bearer <token> Webex uses OAuth2 Bearer tokens. The format must be exactly "Bearer " + token. A wrong format returns 401.

4. Build the payload dict The API requires roomId (or toPersonEmail) plus either text or markdown. Missing roomId returns 400 Bad Request.

5. Call requests.post(url, headers=headers, json=payload) Using json= (not data=) automatically sets Content-Type: application/json and serializes the dict. Using data= with a raw string would require manual serialization and header setting.

6. Check response.status_code A 200 confirms delivery. Skipping this means silent failures are undetectable.


What Goes Wrong Out of Order

Skipped stepResult
No Authorization header401 Unauthorized
Wrong HTTP method (GET instead of POST)405 Method Not Allowed
data= instead of json=400 Bad Request (body not parsed)
Missing roomId in payload400 Bad Request

Memory Tip

"HURP" - Headers (Bearer token), URL (webexapis.com/v1/messages), RoomId in payload, Post request.


If you can share the actual exhibit image or paste the code options, I can give you the exact drag-and-drop answer.

Topics

#Webex Teams API#ChatOps#Python scripting#Notifications

Community Discussion

No community discussion yet for this question.

Full 300-835 Practice