04-07-2019 05:07 AM - edited 04-07-2019 05:09 AM
First off I am warning everyone I am not a coder :)
I am playing around with ERS API to try and do a bulk import of mac addresses to an endpoint identity group.
I am using postman for now but I assume will probably need to convert to curl later once I get the syntax working through postman and everything is confirmed working fine.
I can successfully add an endpoint to an endpoint identity group by doing the following:
POST https://<ise-ip>:9060/ers/config/endpoint
Accept application/json
Content-Type application/json
{
"ERSEndPoint" : {
"name" : "Rebuild_Device",
"description" : "Device to be rebuilt",
"mac" : "00:01:02:03:04:05",
"groupId" : "2e23f7a0-5922-11e9-9392-9a776bb3096a",
"staticGroupAssignment" : true
}
}
Now I want to be able to create a csv or xml file with a list of all the mac addresses to be added to the endpoint identity group. What would my csv/xml file look like (I only care really about the mac addresses of the endpoint)? And how do I code the POST body to use the data in the xml/csv file?
Solved! Go to Solution.
04-08-2019 12:55 AM - edited 04-08-2019 12:56 AM
Hi
Let me give you some idea on this.
You can use python for this operation.
Following will be the workflow.
1. Open the csv/txt file which contains mac address list & store the values as a variable (maclist)
2. Pass the ers credentials & header in variables.
3. Create a 'for' loop to iterate the mac address present in the text file.
4. Payload will be {"ERSEndPoint" : {"mac" : "mac", "groupId" : "2e23f7a0-5922-11e9-9392-9a776bb3096a", "staticGroupAssignment" : true}}
5. URL will be https://<ise-ip>:9060/ers/config/endpoint with post request.
6. Check the http status is 201 or not.
Example:
1. maclist = open('MAC.txt','r') #Open the sheet, read & store it under 'maclist' variable#
2. address = maclist.readlines() # Read the mac address list & store it in 'address' variable#
3. credentails = 'Pass the credentials' & create header with accept,authorization
4. for mac in address: # iterate the for loop for mac in range 'address' variable list #
loginurl = 'https://<ise-ip>:9060/ers/config/endpoint'
payload ={"ERSEndPoint" : {"mac" : "mac", "groupId" : "2e23f7a0-5922-11e9-9392-9a776bb3096a", "staticGroupAssignment" : true}}
req = session.post(loginurl,json = payload,headers)
Note:Even am not a coder.
-Aravind
04-08-2019 08:20 AM
04-08-2019 12:55 AM - edited 04-08-2019 12:56 AM
Hi
Let me give you some idea on this.
You can use python for this operation.
Following will be the workflow.
1. Open the csv/txt file which contains mac address list & store the values as a variable (maclist)
2. Pass the ers credentials & header in variables.
3. Create a 'for' loop to iterate the mac address present in the text file.
4. Payload will be {"ERSEndPoint" : {"mac" : "mac", "groupId" : "2e23f7a0-5922-11e9-9392-9a776bb3096a", "staticGroupAssignment" : true}}
5. URL will be https://<ise-ip>:9060/ers/config/endpoint with post request.
6. Check the http status is 201 or not.
Example:
1. maclist = open('MAC.txt','r') #Open the sheet, read & store it under 'maclist' variable#
2. address = maclist.readlines() # Read the mac address list & store it in 'address' variable#
3. credentails = 'Pass the credentials' & create header with accept,authorization
4. for mac in address: # iterate the for loop for mac in range 'address' variable list #
loginurl = 'https://<ise-ip>:9060/ers/config/endpoint'
payload ={"ERSEndPoint" : {"mac" : "mac", "groupId" : "2e23f7a0-5922-11e9-9392-9a776bb3096a", "staticGroupAssignment" : true}}
req = session.post(loginurl,json = payload,headers)
Note:Even am not a coder.
-Aravind
04-08-2019 08:20 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide