cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
993
Views
10
Helpful
3
Replies

ISE API noob. Having trouble creating endpoint via the API with Python

ab23
Level 1
Level 1

I'm trying to create an endpoint via the API and assign it to a specific group and can't figure out where I'm going wrong. Can someone give me a hint? 

 

CONFIG_ENDPOINT_URL="config/endpoint"
CONFIG_ENDPOINT_GROUP = "config/endpointgroup/"
 
#headers
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}
 
ERSEndPoint = {
"name" : "Test Import1",
"description" : "Test import device1",
"mac" : "00:DE:AD:BE:EF:10",
"groupId" : "20e24",
"staticGroupAssignment" : true,
"staticGroupAssignmentDefined" : true
}

 
response = requests.post(ISE_LAB_URL + CONFIG_ENDPOINT_URL, data=ERSEndPoint, headers=headers, auth=API_ERS_USER)
print((json.dumps(response.json(), indent=4, sort_keys=True)),"_" * 100)
 
 
I run the command and then I'll get an output saying "true" isn't defined. 
 
ISE_ADD_ENDPOINT.py
Traceback (most recent call last):
File "/Users//Python/ISE_ADD_ENDPOINT.py", line 25, in <module>
"staticGroupAssignment" : true,
NameError: name 'true' is not defined
 
 
So I'll remove the two lines with "true" in them just to see what happens and I'll get this error:
 
/ISE_ADD_ENDPOINT.py
{
"ERSResponse": {
"link": {
"href": "https://:9060/ers/config/endpoint",
"rel": "related",
"type": "application/xml"
},
"messages": [
{
"code": "Application resource validation exception",
"title": "Invalid JSON Input: Unrecognized token 'name': was expecting \n at [Source: java.io.StringReader@11c71876; line: 1, column: 5]",
"type": "ERROR"
}
],
"operation": "POST-create-endpoint"
}
} ________________________________________________________________________________
1 Accepted Solution

Accepted Solutions

thomas
Cisco Employee
Cisco Employee

See ISE ERS API Examples for this exact example and more:

 

We also have https://cs.co/ise-youtube with multiple webinars on how to do ISE REST APIs like :
ISE REST APIs Introduction
You can look at the Show Notes and jump ahead to the topic(s) you want.

I also have a GitHub repository with all of the examples in the webinar for you to copy and paste :
https://github.com/1homas/20221004_ISE_REST_APIs_Introduction

Since you appear to be using Python, you may also want
https://github.com/1homas/ISE_Python_Scripts

When submitting code, please use the Insert Code option so it is easier to read:

thomas_0-1671745534797.png

This is what you want:

 

curl  --include  --insecure  --location \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --user $ISE_USERNAME:$ISE_PASSWORD  \
  --request POST https://$ISE_HOSTNAME/ers/config/endpoint \
  --data '
{
  "ERSEndPoint" : {
    "name" : "Test Endpoint",
    "description" : "My new endpoint",
    "mac" : "00:01:02:03:04:05",
    "groupId" : "a1bb2030-8c01-11e6-996c-525400b48521",
    "staticGroupAssignment" : true
  }
}'

 

 

View solution in original post

3 Replies 3

thomas
Cisco Employee
Cisco Employee

See ISE ERS API Examples for this exact example and more:

 

We also have https://cs.co/ise-youtube with multiple webinars on how to do ISE REST APIs like :
ISE REST APIs Introduction
You can look at the Show Notes and jump ahead to the topic(s) you want.

I also have a GitHub repository with all of the examples in the webinar for you to copy and paste :
https://github.com/1homas/20221004_ISE_REST_APIs_Introduction

Since you appear to be using Python, you may also want
https://github.com/1homas/ISE_Python_Scripts

When submitting code, please use the Insert Code option so it is easier to read:

thomas_0-1671745534797.png

This is what you want:

 

curl  --include  --insecure  --location \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --user $ISE_USERNAME:$ISE_PASSWORD  \
  --request POST https://$ISE_HOSTNAME/ers/config/endpoint \
  --data '
{
  "ERSEndPoint" : {
    "name" : "Test Endpoint",
    "description" : "My new endpoint",
    "mac" : "00:01:02:03:04:05",
    "groupId" : "a1bb2030-8c01-11e6-996c-525400b48521",
    "staticGroupAssignment" : true
  }
}'

 

 

Thank you Thomas. Appreciate the response. 

Fixed my own issue.