on
03-17-2017
10:31 AM
- edited on
03-18-2019
07:31 PM
by
thomas
This document focuses around using the ISE API for working with portal settings and elements using the API for Guest & BYOD portals and flows. For guest/sponsor specific document see: ISE Guest Sponsor API Tips & Tricks.
There are samples, however please note we can't comment on coding here, its on your own with outside support. Cisco does have a DevNet developer forum that might be able to assist further but this is above support here and with the TAC.
Please see the API Reference for how to configure an ERS API user.
You will then be able to access
https://<ISE-ADMIN-NODE>:9060/ers/sdk
Thanks to @hslai and @jpujol for this
ISE 2.2+ has ERS API for Self Registered Portal and Sponsored Guest Portal.
Use the browser extension called Postman or any other script to set the passcode on the hotspot portal using JSON:
PUT https://<isePAN>:9060/ers/config/hotspotportal/{ID} with :
"aupSettings" : {
accessCode : “<codehere>”
}
""" Modify the ISE Hotspot portal Access Code tested on ISE 2.3.0.298, python 3.5.2 requires the portal-id """ __author__ = "Jean-Francois Pujol, Cisco Switzerland" __copyright__ = "free to be re-used as needed; Oct 2017" import string, unicodedata, base64 import argparse import requests import json requests.packages.urllib3.disable_warnings() iseServer = "ise.rollelab.ch" username = 'ersadmin' password = ‘xxxxxx’ # plain password baseUrl = 'https://' + iseServer + ':9060/ers/' def setHeaders(username,password): authString = username + ':' + password b64AuthString = base64.b64encode(authString.encode('utf-8')) authHeader = 'Basic ' + b64AuthString.decode('utf-8') iseHeader = {'Authorization' : authHeader , 'Accept': 'application/json' , 'Content-Type': 'application/json'} return (iseHeader) def main(): # Script arguments parser = argparse.ArgumentParser(prog='setHotSpotAccessCode.py', description='Modify ISE portal Access Code ') parser.add_argument('--portalId', help='Guest portal ID', action='store',dest='portalID') parser.add_argument('--code', help='specify a new password', action='store',dest='aCode') args = parser.parse_args() if (args.portalID): portalID = args.portalID else: print('Error: missing --portalId argument') exit(-1) url = baseUrl + 'config/hotspotportal/' + portalID headers = setHeaders(username,password) req = requests.get(url, headers=headers, verify=False) if req.status_code != 200: print("Error; unable to get a correct answer; retcode = " + str(req.status_code) ) exit(1) jsonData = req.json() try: oldAccessCode = jsonData['HotspotPortal']['settings']['aupSettings']['accessCode'] except: print('error: no Access Code found in this portal') exit(1) print('Current access code : ' + oldAccessCode) if (args.aCode): aCode = args.aCode else: exit(0) jsonData['HotspotPortal']['settings']['aupSettings']['accessCode'] = aCode req = requests.put(url, headers=headers, data=json.dumps(jsonData), verify=False) if req.status_code != 200: print("Error; unable to set the new access code; retcode = " + str(req.status_code) ) exit(1) print("Access code successfully set to : " + aCode) exit(0) if __name__ == "__main__": main()
""" Modify the ISE Hotspot portal Access Code tested on ISE 2.3.0.298, python 2.7.6 requires the portal-id """ __author__ = "Jean-Francois Pujol, Cisco Switzerland" __copyright__ = "free to be re-used as needed; Sep 2017" import string, unicodedata, base64 import argparse import requests import json requests.packages.urllib3.disable_warnings() from pprint import pprint iseServer = "ise.rollelab.ch" username = 'ersadmin' #password = 'xxxxxxxxxxxMjM=' # password encoded in base64 password = 'xxxxxx' # plain password baseUrl = 'https://' + iseServer + ':9060/ers/' def main(): # Script arguments parser = argparse.ArgumentParser(prog='setHotSpotAccessCode.py', description='Modify ISE portal Access Code ') parser.add_argument('--portalId', help='Guest portal ID', action='store',dest='portalID') parser.add_argument('--code', help='specify a new password', action='store',dest='aCode') args = parser.parse_args() if (args.portalID): portalID = args.portalID else: print('Error: missing --portalId argument') exit(-1) url = baseUrl + 'config/hotspotportal/' + portalID auth_string = 'Basic ' + base64.b64encode(username + ':' + password) #auth_string = 'Basic ' + base64.b64encode(username + ':' + password.decode('base64')) headers = { 'Authorization' : auth_string, 'Accept' : 'application/json', 'Content-Type' : 'application/json' } req = requests.get(url, headers=headers, verify=False) if req.status_code != 200: print("Error; unable to get a correct answer; retcode = " + str(req.status_code) ) exit(1) jsonData = req.json() try: oldAccessCode = jsonData['HotspotPortal']['settings']['aupSettings']['accessCode'].encode('ascii') except: print('error: no Access Code found in this portal') exit(1) print('Current access code : ' + oldAccessCode) if (args.aCode): aCode = args.aCode else: exit(0) jsonData['HotspotPortal']['settings']['aupSettings']['accessCode'] = aCode.encode('utf-8') req = requests.put(url, headers=headers, data=json.dumps(jsonData), verify=False) if req.status_code != 200: print("Error; unable to set the new access code; retcode = " + str(req.status_code) ) exit(1) print("Access code successfully set to : " + aCode) exit(0) if __name__ == "__main__": main()
""" Modify the ISE guest portal Access Code tested on ISE 2.2.0.470, python 2.7.6 requires the portal-id """ __author__ = "Jean-Francois Pujol, Cisco Switzerland" __copyright__ = "free to be re-used as needed; Apr 2017" import string, unicodedata, base64 import argparse import requests import json requests.packages.urllib3.disable_warnings() iseServer = "ise.rollelab.ch" username = 'ersadmin' password = 'cisco' # plain password baseUrl = 'https://' + iseServer + ':9060/ers/' def main(): # Script arguments parser = argparse.ArgumentParser(prog='setAccessCode.py', description='Modify ISE portal Access Code ') parser.add_argument('--portalId', help='Guest portal ID', action='store',dest='portalID') parser.add_argument('--code', help='specify a new password', action='store',dest='aCode') args = parser.parse_args() if (args.portalID): portalID = args.portalID else: print('Error: missing --portalId argument') exit(-1) url = baseUrl + 'config/sponsoredguestportal/' + portalID auth_string = 'Basic ' + base64.b64encode(username + ':' + password) headers = { 'Authorization' : auth_string, 'Accept' : 'application/json', 'Content-Type' : 'application/json' } req = requests.get(url, headers=headers, verify=False) if req.status_code != 200: print("Error; unable to get a correct answer; retcode = " + str(req.status_code) ) exit(1) jsonData = req.json() try: oldAccessCode = jsonData['SponsoredGuestPortal']['settings']['selfRegPageSettings']['registrationCode'].encode('ascii') except: print('error: no Access Code found in this portal') exit(1) print('Current access code : ' + oldAccessCode) if (args.aCode): aCode = args.aCode else: exit(0) jsonData['SponsoredGuestPortal']['settings']['selfRegPageSettings']['registrationCode'] = aCode.encode('utf-8') req = requests.put(url, headers=headers, data=json.dumps(jsonData), verify=False) if req.status_code != 200: print("Error; unable to set the new access code; retcode = " + str(req.status_code) ) exit(1) print("Access code successfully set to : " + aCode) exit(0) if __name__ == "__main__": main()
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: