2.3.2.3 Lab - Using Python To Automate Listing Rooms
2.3.2.3 Lab - Using Python To Automate Listing Rooms
Objectives
• Prompt the users for their access token else use the hard-coded access token.
• Setup the API call by initializing variables to hold the URL and header information.
• Display a list of the user's Webex Teams rooms in JSON format.
Background / Scenario
Python can be used to perform the same API calls that can be made in Cisco Webex for Developers and
Postman. This lab introduces you to using existing Python code to create a simple API call for listing Webex
Teams rooms.
This program first asks users if they want to use their own access token or a generic one. If the answer is no,
users are prompted to provide their own access token. If the answer is yes, then an access token value that is
written in the code is used. After the access token value is established, the program sets up the API request
by initializing variables that contain the required header information and the URl of the Webex Teams rooms
API endpoint. These values are used to make the request with the requests.get() method. Finally, the
response JSON that contains the list of rooms is displayed.
Required Resources
• Webex Teams account
• Webex Teams desktop application
• Python 3 with IDLE
• Python code files
2017 - 2018 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 1 of 2 www.netacad.com
Lab - Using Python to Automate Listing Rooms
Step 2: Add the URL for the Webex Teams rooms endpoint.
a. Go to Student Step #2 in the code. Within the file, locate the statement:
apiUri = "<!!!REPLACEME with URL for Webex Teams Rooms API!!!>"
b. Replace <!!!REPLACEME wtih URL for Webex Teams Rooms API!!!> with
https://api.ciscospark.com/v1/rooms.
Reflection
1. Look for the section of the code that sends the API request to the URL. What are the values that are required
by this method?
_______________________________________________________________________________________
_______________________________________________________________________________________
2. What variable contains the actual response from the API?
_______________________________________________________________________________________
_______________________________________________________________________________________
3. Python is well-suited to working with JSON because JSON can easily be converted into Python dictionaries
and lists. What variable contains the JSON that has been converted to Python?
_______________________________________________________________________________________
_______________________________________________________________________________________
2017 - 2018 Cisco and/or its affiliates. All rights reserved. Cisco Confidential Page 2 of 2 www.netacad.com