01-31-2020 07:19 AM - edited 01-31-2020 12:36 PM
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
01-31-2020 12:55 PM
This is probably the wrong sub-forum of this question.
05-05-2020 06:54 PM
05-06-2020 08:49 AM
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
05-06-2020 11:20 AM
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})
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide