Khurshid_Ali | 2024-05-05 06:36:17 UTC | #1
Hello Forum,
I am new and learning Genesys cloud and data actions on a fast pace as per the requirements.
I want to validate on my digital bot flow if the user is a supervisor, if yes, take one action if not, take another action.
have explored these APIs: GET /api/v2/authorization/subjects/{subjectId}: Returns a listing of roles and permissions for a user. GET /api/v2/users/{subjectId}/roles: Returns a listing of roles and permissions for a user.GET
both gives me a list of users or roles.
How do I either filter specific role to a user or specific user to a role? I believe either would work for me.
Thanks.
Jason_Mathison | 2024-05-06 13:46:04 UTC | #2
I am basing this answer on the /api/v2/authorization/subjects/me route which I had easy access to. You would have to modify this if the routes you are using give a different response shape.
I took the response from the API and put it in here (this isn't a Genesys site, so I wouldn't paste anything sensitive here): https://www.javainuse.com/jsonpath
I came up with this as the JSONPath to check if my user has the specified role name:
.grants..role[?(@.name == "Communicate - User")].name
If my user doesn't have it, it will return an empty array. If it does have the role, the role will end up in the response. If you want a boolean out of that you could do a contains on the variable to see if the name is in it.
--Jason
system | 2024-06-06 13:46:44 UTC | #3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 26087