05-04-2021 01:41 AM - edited 05-18-2021 03:04 AM
Hello Everyone ,
I like to create Internal User with python scripts but I got an error
Traceback (most recent call last):
File "C:\Users\ghibuser\Desktop\ISEInternalUserTest.py", line 38, in <module>
req_body_json = """{{
IndexError: Replacement index 8 out of range for positional args tuple
This is my command for run my python code for ISE
python ISEInternalUserTest.py 192.198.1.2 ers-admin admin robert Robert Mensah Password1 rmensah@gmail.com Employee 12/27/2021
Any suggestions are welcome to help me run this code for my work project better
Thank you
Richard
Solved! Go to Solution.
05-04-2021 07:30 AM
Richard,
Many of your questions are answered in the document ISE ERS API Examples.
We have an example of creating a user under Create an Internal User with cURL and JSON.
This shows you what the JSON data looks like that you need to send to ISE.
I used my Postman collection for the ISE ERS APIs to generate the Python code below. Please watch our ISE REST API webinar for how I generated this code as a starting point for your project. I highly recommend you watch the entire webinar.
53:47 Postman Code Snippets
Once you get the basic submission working, I recommend using the Python library argparse for command line arguments in your program.
import requests
import json
url = "https://ise.securitydemo.net:9060/ers/config/internaluser"
payload = json.dumps({
"InternalUser": {
"name": "{{username}}",
"password": "{{password}}",
"description": "{{description}}"
}
})
# You will need to update this with your username+password credentials
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic e3tyZXN0X3VzZXJuYW1lfX06e3tyZXN0X3Bhc3N3b3JkfX0='
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
05-04-2021 07:30 AM
Richard,
Many of your questions are answered in the document ISE ERS API Examples.
We have an example of creating a user under Create an Internal User with cURL and JSON.
This shows you what the JSON data looks like that you need to send to ISE.
I used my Postman collection for the ISE ERS APIs to generate the Python code below. Please watch our ISE REST API webinar for how I generated this code as a starting point for your project. I highly recommend you watch the entire webinar.
53:47 Postman Code Snippets
Once you get the basic submission working, I recommend using the Python library argparse for command line arguments in your program.
import requests
import json
url = "https://ise.securitydemo.net:9060/ers/config/internaluser"
payload = json.dumps({
"InternalUser": {
"name": "{{username}}",
"password": "{{password}}",
"description": "{{description}}"
}
})
# You will need to update this with your username+password credentials
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic e3tyZXN0X3VzZXJuYW1lfX06e3tyZXN0X3Bhc3N3b3JkfX0='
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
05-04-2021 09:50 AM
Can I use this Guest User Creation script for Internal User format as well .
https://developer.cisco.com/docs/identity-services-engine/3.0/#!create-guest-user
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: