List of users assigned to a role

Hi,

I appear to be having an issue with the Python SDK specifically with endpoint /api/v2/authorization/roles/{roleId}/users.

If I use this endpoint via dev tools then I receive the expected result which can be seen below:

"entities": [
{
"id": "9e97fd15-2cba-gh78-9d60-c96b1aa6b266",
"selfUri": "/api/v2/users/9e97fd15-gh78-4d91-9d60-c96b1aa6b266"
},
{
"id": "661c4d7c-ccb6-lo90-b89c-c878c0e4be77",
"selfUri": "/api/v2/users/661c4d7c-lo90-452d-b89c-c878c0e4be77"
},

however, if I use get_authorization_role_users() via Python SDK then I get an entirely different result which can be seen below:

{'acd_auto_answer': None,
'addresses': None,
'authorization': None,
'biography': None,
'certifications': None,
'chat': None,
'conversation_summary': None,
'department': None,
'division': None,
'email': None,
'employer_info': None,
'geolocation': None,
'groups': None,
'id': '31c0810a-172f-4846-8411-0941de9ba911',
'images': None,
'language_preference': None,
'languages': None,
'last_token_issued': None,
'locations': None,
'manager': None,
'name': None,
'out_of_office': None,
'presence': None,
'primary_contact_info': None,
'profile_skills': None,
'routing_status': None,
'self_uri': '/api/v2/users/31c0810a-172f-4846-8411-0941de9ba911',
'skills': None,
'state': None,
'station': None,
'team': None,
'title': None,
'username': None,
'version': None}],

Is this expected from the Python SDK if so, then I can iterate through the JSON and return the self_uri I suppose.

Thanks in advance

You're probably authorizing the requests using different entities. The dev tools website authorizes using a user. I'm guessing you're authorizing the python SDK using client credentials, which is not related to your user and can have different permissions.

Hi Tim,

Thank you, I am using client credentials via Python and I am iterating through a list of roles to then return the list of users that's assigned to the role.

This is what I am using as an example:

roleList = [
"60a63986-4de2-44e1-ad29-fb5f9d155636",
"60a63986-4de2-44e1-ad29-fb5f9d155636",
"60a63986-4de2-44e1-ad29-fb5f9d155636",
]

def getUsers():

      for role in roleList:
            r = autho.get_authorization_role_users(role, page_size=500)
            print("-----------------------------------------------------------------------")
            print("Role:", role)
            print("-----------------------------------------------------------------------")
            for i in r.entities:
                  print(i.id)

Oh I think I see what you're getting at. You mean that the result is "entirely different" because dumping the python object to the console prints stuff like 'acd_auto_answer': None, right? I'd expect that with Python. The actual HTTP payload from the API only includes what you see in the dev tools. But when you trace out the python object, it prints out all the properties that are defined on the model; the None value indicates that there wasn't a value for that property in the response payload.

If that's what you meant, I'd say it's working as expected because python classes have an explicit structure and JSON objects don't.

Thanks Tim for clearing that up.

I have noticed that the id's returned from the python script are not user id's and I am getting the error below when I try and get the user. Unless they are user id's and there is another issue somewhere. They do look like user id's as this is the self_uri returned /api/v2/users/bbe9cd4a-8f32-4689-9ec0-332233686389'

{
  "message": "Entity [user] is not found by id [77f9b1d9-27aa-457f-a3a8-fc789a10276a]",
  "code": "general.resource.not.found",
  "status": 404,
  "messageParams": {
    "fieldName": "user",
    "errorCode": "GENERAL_RESOURCE_NOT_FOUND"
  },
  "contextId": "12ce8457-044e-438c-bc11-68ecc51cf5df",
  "details": [],
  "errors": []
}

I don't have access to be able to tell if that user is deleted in your org, but that seems like a likely cause. Try making the request with the state=deleted query param and see if you get data. Try it out using the new API tools in the Developer Center Beta! Genesys Cloud Developer Center

It's possible that divisions might have something to do with it. You obviously can't look up that user to see what division they're in, but if you don't have access to certain divisions that might be something to remedy and try again.

If that's not it, please open a case with Genesys Cloud Care to investigate further. They'll have more access to dig in and figure out how you're getting IDs but not able to fetch the user info.

is it possible for a user to be in multiple divisions?

No, division assignment for the user is done via a dropdown in the UI and exists as a singular property on the user via the API.

The divisions to which a user has access is a plural setting, however. That's a combination of role + divisions when you assign roles.

Hi TIm,

Thank you, I will then have to raise a case with care as my OAuth account already has all divisions assigned.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.