Hi All,
I am trying to print/save to csv file the list of members which has schema as below: Name, email, role and group , I am able to print only Name and email. But not the role and group .
BASE_URL = ‘https://api.clockify.me/api/v1’
WORKSPACE_ID = ‘YOUR_WORKSPACE_ID’
headers = {
‘X-Api-Key’: API_KEY,
‘Content-Type’: ‘application/json’,
}
Make a GET request to fetch team members
response = requests.get(f’{BASE_URL}/workspaces/{WORKSPACE_ID}/team/members’, headers=headers)
Check if the request was successful
if response.status_code == 200:
team_members = response.json()
# Extract name, email, role, and group information from the team members
for team_member in team_members:
name = team_member['user']['name']
email = team_member['user']['email']
role = team_member['role']
group = team_member['group']['name']
# Print the team member information
print(f'Name: {name}')
print(f'Email: {email}')
print(f'Role: {role}')
print(f'Group: {group}')
print('---')
else:
print(f’Failed to fetch team members. Response: {response.text}')
What could be the reason?
any help could be appreciated.
Regards,
Venkat