nerdexam
Cisco

200-901 · Question #243

Drag and Drop Question Refer to the exhibit. A developer needs to automatically retrieve all of the messages of a Webex room with the roomId of…

The correct answer is messages?; room_id; webex_token. This question assesses the candidate's ability to interpret API documentation to correctly construct a Webex API request URL and authorization header for listing messages in a room using a Python script.

Understanding and Using APIs

Question

Drag and Drop Question Refer to the exhibit. A developer needs to automatically retrieve all of the messages of a Webex room with the roomId of “Y2lzY29zcGFyazovL3Vz397468502YjU5NjAtNTk0Zi0xMWVhLTk0Mj”. Using the Webex API documentation shown, drag and drop the code snippets from below onto the code to complete the Python script to list all of the messages in the room. Not all options are used. Answer:

Exhibit

200-901 question #243 exhibit

Answer Area

Drag items

room_idwebex_tokenmessages?

Correct arrangement

  • messages?
  • room_id
  • webex_token

Explanation

This question assesses the candidate's ability to interpret API documentation to correctly construct a Webex API request URL and authorization header for listing messages in a room using a Python script.

Approach. The objective is to complete the Python script to make a GET request to the Webex API to list messages in a specific room. Based on the provided API documentation for 'List Messages':

  1. URL Construction:

    • The base URL is 'https://webexapis.com/v1/'.
    • The documentation specifies the endpoint as '/v1/messages' and the example URL shows 'messages?roomId=...'. Thus, the first blank after '/v1/' should be 'messages?' to correctly initiate the query parameters.
    • The query parameter required is 'roomId' to specify the room ID. So, the second blank should be 'roomId'.
    • The value for the 'roomId' query parameter comes from the Python variable 'room_id' defined earlier in the script. Therefore, the third blank (after '="') should be 'room_id'.
    • Correct drag actions for the URL line: Drag 'messages?' to the first blank, then 'roomId' to the second blank, and 'room_id' to the third blank.
  2. Authorization Header:

    • API requests typically require authentication. The script sets up an 'Authorization' header with 'Bearer '.
    • The authentication token is provided in the 'webex_token' variable. Therefore, the blank after "'Bearer ' +" should be 'webex_token'.
    • Correct drag action for the headers line: Drag 'webex_token' to the blank after "'Bearer ' +".

Following these steps constructs the correct API request URL and includes the necessary authorization token.

Common mistakes.

  • common_mistake. Common mistakes include:
  • Dragging 'messages' instead of 'messages?': While 'messages' is part of the endpoint, the '?' is critical to correctly signify the start of query parameters. Without it, 'roomId' would not be parsed as a query parameter, leading to an incorrect URL and API request failure.
  • Dragging 'room' instead of 'roomId': The API documentation explicitly defines the query parameter name as 'roomId' (case-sensitive). Using 'room' would result in an invalid request parameter, and the API would not return the expected results.
  • Dragging 'room' instead of 'room_id' for the variable value: The Python script defines the variable holding the room ID as 'room_id'. Using 'room' (without the underscore) would lead to a Python 'NameError' because 'room' is not a defined variable.
  • Not placing 'webex_token' in the 'Authorization' header: Authentication is a fundamental security requirement for most API calls. Omitting or misplacing the 'webex_token' in the 'Bearer' authorization string would result in an 'Unauthorized' (HTTP 401) error, preventing the request from succeeding.

Concept tested. The core concepts tested are API integration fundamentals, specifically constructing RESTful API request URLs (including base URL, endpoint path, and query parameters), implementing authentication using Bearer tokens in HTTP headers, interpreting technical API documentation, and basic Python syntax for variable usage and string manipulation.

Topics

#Webex API#Python#REST API#API Integration

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice