300-835 · Question #77
Refer to the exhibit. The code includes the beginning of a short Python script that is constructed to notify in the guard in case of an intruder alert. Which code snippet completes the script?
The correct answer is D. request.post('https://api.ciscospark.com/v1/messages', headers = {'Authorization': 'Bearer ' + token }, data = { 'toPersonEmail': '[email protected]', 'markdown': '**Warning!** Intruder alert in Section 12' } ). Option D is correct because sending a new message in the Cisco Spark (Webex) API requires a POST request to the /v1/messages endpoint, targeting a recipient via toPersonEmail with a markdown-formatted body - all of which D provides correctly. Why the distractors fail: A uses PUT
Question
Options
- Arequest.put('https://api.ciscospark.com/v1/rooms' + room, headers = { 'Authorization': 'Bearer ' + token }, data = { 'toPersonEmail': '[email protected]', 'html': '<b>Warning!</b> Intruder alert in Section 12' } )
- Brequest.post('https://api.ciscospark.com/v1/messages', headers = {'Authorization': 'Bearer ' + token }, data = { 'roomId': 'Perimeter Guard Space', 'markdown': 'Warning! Intruder alert in Section 12' } )
- Crequest.post('https://api.ciscospark.com/v1/rooms' + room, headers = {'Authorization': 'Bearer ' + token }, data = { 'text': 'Warning! Intruder alert in Section 12' 'markdown': 'Warning! Intruder alert in Section 12' } )
- Drequest.post('https://api.ciscospark.com/v1/messages', headers = {'Authorization': 'Bearer ' + token }, data = { 'toPersonEmail': '[email protected]', 'markdown': 'Warning! Intruder alert in Section 12' } )
How the community answered
(41 responses)- A17% (7)
- B7% (3)
- C2% (1)
- D73% (30)
Explanation
Option D is correct because sending a new message in the Cisco Spark (Webex) API requires a POST request to the /v1/messages endpoint, targeting a recipient via toPersonEmail with a markdown-formatted body - all of which D provides correctly.
Why the distractors fail:
- A uses
PUT(for updating existing resources) instead ofPOST, targets the wrong/v1/roomsendpoint, and uses anhtmlfield that isn't a valid Spark message parameter. - B uses the correct method and endpoint but passes
'roomId': 'Perimeter Guard Space'- aroomIdmust be a unique system ID, not a human-readable room name; this would fail to resolve. - C posts to
/v1/rooms(which creates/manages rooms, not messages) and contains a syntax error: two dictionary values are written back-to-back without a separating comma.
Memory tip: Think "POST a message, email the person" - you're creating (POST) a new message (/v1/messages), and you identify a direct-message recipient with toPersonEmail, not a room name or a PUT update.
Topics
Community Discussion
No community discussion yet for this question.