Hi Everyone,
I’m experiencing a bit of trouble, and wondering if someone could shed light on what I’m doing wrong.
I want to list all our user accounts individually, on a separate line, like this:
Found User Account: bobjackson@company.org
Found User Account: janedoe@company.org
Found User Account: johnsmith@company.org
With the Python Requests library, I managed to page through the JSON results and get all users in an array. Fine. But what I’m having difficulties with is printing out the email of each individual user.
These are the results I’m getting:
Found User Account: [‘bobjackson@company.org’, ‘janedoe@company.org’, ‘johnsmith@company.org’]
Found User Account: [‘kensmith@company.org’,‘loisjackson@company.org’,‘marysmith@company.org’]
Found User Account: [‘nancydoe@company.org’,‘oscarmartinez@company.org’,‘paulmorgan@company.org’]
This is the Python code I’m using:
import requests url_address = "https://api.zoom.us/v2/users" headers = { "Authorization": "Bearer " + "MY_JWT_TOKEN", } # find out total number of pages r = requests.get(url=url_address, headers=headers).json() total_pages = int(r['page_count']) + 1 # results will be appended to this list all_entries = [] # loop through all pages and return JSON object for page in range(1, total_pages): url = url_address + "?page_number=" + str(page) user_data = requests.get(url=url, headers=headers).json() user_ids = [(user['email']) for user in user_data['users']] all_entries.append(user_ids) page += 1 data = list(all_entries) for email in data: print('Found User Account: {}'.format(email))
Any help would be GREATLY appreciated. Many thanks in advance!