cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1961
Views
5
Helpful
2
Replies

ISE Internal User Creation with Python Program

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

1 Accepted Solution

Accepted Solutions

thomas
Cisco Employee
Cisco Employee

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)

 

View solution in original post

2 Replies 2

thomas
Cisco Employee
Cisco Employee

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)

 

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

Getting Started

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:

Recognize Your Peers