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

ERS returns max 20 Endpoints

Arne Bier
VIP
VIP

Hi

I have written a python script to dump some data from the Endpoints table that relates to Guest users.  I want to see all the MAC addresses and whether or not there are guest users associated with them.

The issue is that ISE 2.3 ERS (External RESTful Service) only returns 20 MAC addresses and then stops with this JSON output.

   "nextPage" : {

      "rel" : "next",

      "href" : "",

      "type" : "application/xml"

    }

  }

}

How do I get it to show me more than 20 endpoints?

I found a forum posting

Query endpoints with REST API

that had a similar question but that was long ago.  Has anything changed since then? 

If the API is limited to returning 20 items only then that surely has to be customizable

thanks

Arne

1 Accepted Solution

Accepted Solutions

Craig Hyps
Level 10
Level 10

The default query size is 20. 

Review the online SDK under the Quick Reference menu > Searching a Resource.

For example, You can increase query size by 50 and page to 5 (5th page in groups of 50) by appending query with ?size=50&page=5

Craig

View solution in original post

2 Replies 2

Craig Hyps
Level 10
Level 10

The default query size is 20. 

Review the online SDK under the Quick Reference menu > Searching a Resource.

For example, You can increase query size by 50 and page to 5 (5th page in groups of 50) by appending query with ?size=50&page=5

Craig

thanks for the information.  I literally only started on this journey yesterday and my eyes are wide open now - it's not as simple as I thought.  The sample scripts are good to get you off the ground, but I would like to know how to handle this page-by-page business.  e.g. is it normal to get chunks of 20 results back, and then keep requesting the next chunk of 20 results until I have what I need, or reached the end?

Perhaps this question belongs in DevNet (and if anyone has links or guidance I would appreciate it), but here is the core of my Python script, and I need to know what changes I need to make to it to handle the complete results set (i.e. retrieve all results)

import http.client
import base64
import ssl
import sys
import json

# host and authentication credentials
#host = "10.220.113.42"
host = "10.220.69.42"
user = "ersguest"
password = "Encryption123"


conn = http.client.HTTPSConnection("{}:9060".format(host), context=ssl.SSLContext(ssl.PROTOCOL_TLSv1_2))

creds = str.encode(':'.join((user, password)))
encodedAuth = bytes.decode(base64.b64encode(creds))

headers = {
    'accept': "application/json",
    'authorization': " ".join(("Basic",encodedAuth)),
    'cache-control': "no-cache",
    }

conn.request("GET", "/ers/config/guestuser/", headers=headers)

res = conn.getresponse()
data = res.read()

Rawjsondata = json.loads(data.decode("utf-8"))
blob = Rawjsondata["SearchResult"]["resources"]

for item in blob:
    print (item["name"],",",end='') # print the Guest name
    conn.request("GET", item["link"]["href"], headers=headers) #Fetch the guest details data
    res = conn.getresponse()
    data = res.read()
    Rawjsondata = json.loads(data.decode("utf-8"))
    subblob = Rawjsondata["GuestUser"] # This is the Guest detail containing stuff we want
    print(subblob["guestType"],",",end='') # Guest type
    print(subblob["status"],",",end='') # Guest account status
    print(subblob["guestInfo"]["lastName"],",",end='') # Last name
    print(subblob["guestInfo"]["firstName"],",",end='') # First name
    print(subblob["guestInfo"]["emailAddress"]) # Login username - this is the final item

The result looks like this (I only have 2 guests in my lab currently - but I will create more so that I can test the bulk retrieval)

>>>

RESTART: C:\Users\arne\AppData\Local\Programs\Python\Python36\Scripts\PAN-GetAllGuestUsers.py

jsmith ,Visitor_30 ,ACTIVE ,Smith ,Johnny ,johnny@mail.com

ledmonds ,Visitor_30 ,AWAITING_INITIAL_LOGIN ,Edmonds ,Lisa ,lisa@mail.com