In an effort to retrieve the email address, first, last, and type of the users on our account, I’m trying to use python to get the information via JSON.
I am able to get everything EXCEPT the first_name and last_name fields. Here is what I have been testing with so far:
for page in range(1, total_pages):
url = url_address + "?page_number=" + str(page)
user_data = requests.get(url=url, headers=headers).json()
user_email = [(email['email']) for email in user_data['users']]
user_fname = [(first_name['first_name']) for first_name in user_data['users']]
print(user_email, user_fname)
I know the loop isn’t finished, I’m just trying prints to see what I get at the moment. If I only ask for the email and type, it works perfectly. If I include either first_name or last_name I get the following error:
Traceback (most recent call last):
File "~/Desktop/zoomscript.py", line 43, in <module>
user_fname = [(first_name['first_name']) for first_name in user_data['users']]
File "~/Desktop/zoomscript.py", line 43, in <listcomp>
user_fname = [(first_name['first_name']) for first_name in user_data['users']]
KeyError: 'first_name'
I’m still learning how to use python so I’m sure I have to just be missing something, but I’m not sure what to do. All of the documentation points to being able to ask for first_name and last_name, but nothing I try seems to work.
Any ideas out there?