Hi All,
I'm trying to get all devices in an organization via a Python script and know there is a limit of 1000 devices per page.
The problem is i have 8000 devices so i need to use header links to grabs the next pages.
Being banging my head against the wall for an hour now but cannot seem the figure out how to implement pagination using the following function
def getNetworksDevices(p_orgid):
try:
r = requests.get('https://api.meraki.com/api/v1/organizations/%s/devices' % (p_orgid),headers={'X-Cisco-Meraki-API-Key': ARG_APIKEY,'Content-Type': 'application/json'} )
while r.status_code == 429:
time.sleep(int(r.headers['Retry-After']))
r = requests.get('https://api.meraki.com/api/v1/organizations/%s/devices' % (p_orgid),headers={'X-Cisco-Meraki-API-Key': ARG_APIKEY,'Content-Type': 'application/json'} )
if r.status_code == 200:
return(r.json())
if r.status_code == 200:
return (r.json())
except:
print('ERROR 02: Unable to contact Meraki cloud')
print ('API response: {}'.format(r.status_code))