cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2159
Views
0
Helpful
4
Replies

UCCX REST API for User Roles

tsmith054
Level 1
Level 1

I've been using the REST api to develop some custom tools on the UCCX platform.  I cannot find an API that allows you to assign the "Supervisor" role to an agent.  It's not listed in the official documentation.  You cannot add someone as a supervisor to a team without them having the supervisor role initially.  Is there a way to accomplish this using an API?

 

Screenshot is attached showing the section in UCCX I'm referring too

4 Replies 4

vleijon
Cisco Employee
Cisco Employee

This is probably the wrong sub-forum of this question.

I know it's a bit late, but I moved this message to the Contact Center space.

dekwan
Cisco Employee
Cisco Employee

Hi,

 

Looking at the documentation, I also I do not see an API to assign the supervisor role to a user. There doesn't seem to be a way to assign roles via API.

 

Thanx,

Denise

Anthony Holloway
Cisco Employee
Cisco Employee

I don't think it's available in the API either, but I do know how to "hack" a solution together using Python + Requests to mimic a web interaction.

 

Check out this proof of concept to get you started.  I provide no support on this solution, please do your due diligence when running random code off the internet on your production systems.  ;)

 

#!/usr/bin/env python

import requests
from urllib.parse import parse_qs
from bs4 import BeautifulSoup
requests.packages.urllib3.disable_warnings()

# Connection Info
hostname = "uccx.domain.com"
username = "administrator"
password = "p@assw0rd"
target_user = "aholloway"
target_role = "Supervisor"

# Static URLs
url_base = f"https://{hostname}"
url_appadmin = f"{url_base}/appadmin"
url_main = f"{url_appadmin}/main"
url_login = f"{url_appadmin}/j_security_check"
url_get_token = f"{url_appadmin}/JavaScriptServlet"
url_user_search = f"{url_appadmin}/LDAPSetup?request_type=ldapsetup.waitpage.usermaintenance&wizard=&isonload=false"
url_user_modify = f"{url_appadmin}/LDAPSetup"

# Establish Initial Connection and Get JSESSION Cookie, etc.
connection = requests.Session()
resp = connection.get(url_main, verify = False)

# Get CSRF Token for Session
resp = connection.post(url_get_token, verify = False, headers={'Referer':url_main,'FETCH-CSRF-TOKEN':'1'})
token = resp.content[10:]

# Login to UCCX
form_data = dict(j_username = username, j_password = password)
resp = connection.post(url_login, verify = False, data = form_data)

# Perform User Search to Get Current Capabilities
form_data = {
    "request_type":"ldapsetup.next.usermaintenance",
    "chkLoginUser":"false",
    "search_criteria":target_user",
    "CSRFTOKEN":token
}
resp = connection.post(url_user_search, verify = False, data = form_data, headers={'Referer':url_main,'CSRFTOKEN':token})
soup = BeautifulSoup(resp.content, features="html.parser")
caps = parse_qs(soup.find_all('td', string=target_user)[0].find('a')['href'])['cap'][0]

# Modify the User (assumes at least Agent role exists, and you are adding one or more new roles)
form_data = {
    "request_type":"ldapsetup.userupdate",
    "users":f"{caps},{target_role}",
    "request_type_axl":"ldapsetup.next.usermaintenance",
    "selected_user":target_user,
    "setup":"null",
    "deploymentType":"1",
    "userView":"false",
    "chkLoginUser":"false",
    "CSRFTOKEN":token
}
resp = connection.post(url_user_modify, verify = False, data = form_data, headers={'Referer':url_main})