GetAllEnabledUsers: Python example

 
import sys, json, requests
 
companyKey = 'companyKey' # Replace the Company Key
loginName = 'LoginName' # Replace the Login Name
password = 'Password' # Replace the Password
 
headers = {'content-type':'application/json'}
 
# Finding Swimlane
swimlaneFinderUrl = 'https://global.replicon.com/DiscoveryService1.svc/GetTenantEndpointDetails'
swimlaneFinderJsonBody = {}
tenant = {}
tenant['companyKey'] = companyKey
swimlaneFinderJsonBody['tenant'] = tenant
 
swimlaneInfo = None
 
# Getting the Swimlane information of the Company Key
try:
 
swimlaneFinder = requests.post(swimlaneFinderUrl, headers = headers, data = json.dumps(swimlaneFinderJsonBody))
swimlaneFinder = swimlaneFinder.json()
 
if swimlaneFinder.get('error'):
 
print 'Error: {0}'.format(swimlaneFinder.get('error'))
 
sys.exit(1)
 
else:
 
swimlane = swimlaneFinder['d']['applicationRootUrl']
 
except Exception, e:
 
print 'Error: {0}'.format(e)
 
sys.exit(1)
 
# Getting All enabled Users in the tenant.
try:
 
allEnabledUserUrl = swimlane + 'services/UserService1.svc/GetEnabledUsers'
 
allEnabledUser = requests.post(allEnabledUserUrl, headers = headers, auth = (companyKey+'\\'+loginName, password))
allEnabledUser = allEnabledUser.json()
 
if allEnabledUser.get('error'):
 
print 'Error: {0}'.format(allEnabledUser.get('error'))
 
sys.exit(1)
 
else:
 
for user in allEnabledUser['d']:
 
print user
 
except Exception, e:
 
print 'Error: {0}'.format
 
sys.exit(1)