Getting a list of group members using the API | XM Community
Solved

Getting a list of group members using the API

  • 3 September 2020
  • 2 replies
  • 39 views

Badge +7

Hi everybody!
I feel like I searched the entire API documentation but haven't found what I need: A list of members for a certain group (the same thing could also apply to divisions, for example, but groups are what we currently use). Going to [Admin | Groups] in the UI yields exactly this, by the way, but I want to automate/speed up certain reporting tasks that we have to carry out regularly.
There are instructions on "Managing Groups", "Managing Users", "Get User", "Get Group", however, I see no way of combining the respective API calls into a group member list. Neither do the group-related responses yield a member list nor do the user-related responses contain group affiliations. Am I missing something here?

icon

Best answer by cpschroeder 10 August 2021, 15:42

View original

2 replies

def listObject(object):
  URL = f"{qualtricsBaseURL}/API/v3/{object}"
  headers = {
    'Authorization': f"Bearer {bearerToken}"
  }
   
  result = []
  while URL is not None:
    r = requests.get(URL, headers=headers)
    r.raise_for_status()
    URL = r.json()["result"]["nextPage"]
    result += r.json()["result"]["elements"]
     
  return result

groupId = "GR_...."
listObject("groups/" + groupId + "/members")

Badge +7

Maybe I missed it before, maybe it's new, but there is an API endpoint that does exactly this: List Users in Group. Nonetheless, evgaste1, thanks for your answer!

Leave a Reply