Team Members export to csv file using python

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 .



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(f’Failed to fetch team members. Response: {response.text}')

What could be the reason?
any help could be appreciated.

Hi Venkat,

The endpoint is a bit odd here. Could you try going with this endpoint{workspaceId}/users and see how it goes?


Hi Mishko,
Thanks for your reply!
Yes I did try different options including the above.{workspaceId}/users
I can print Name and Email where as Role and Group is showing blank and not able to get that records.