# Pagination issue when trying to loop through meetings with python

**URL:** <https://devforum.zoom.us/t/pagination-issue-when-trying-to-loop-through-meetings-with-python/28162>\
**Category:** API and Webhooks\
**Created:** [August 25, 2020, 7:48pm UTC](https://devforum.zoom.us/t/pagination-issue-when-trying-to-loop-through-meetings-with-python/28162 "2020-08-25T19:48:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lsteve](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lsteve/32/2178_2.png) [@lsteve](https://devforum.zoom.us/u/lsteve)\
**Post date:** [August 25, 2020, 7:48pm UTC](https://devforum.zoom.us/t/pagination-issue-when-trying-to-loop-through-meetings-with-python/28162/1 "2020-08-25T19:48:30Z")

</div>

I’m new to both Zoom APIs and Python, and I’m running into an issue that I hope is easy to resolve. I am attempting to loop through all meetings to pull back some data. By using the sample code in the API documentation, I have been able to pull back the first page of data, including the value for next\_page\_token. However, I am stuck at trying to use next\_page\_token in order to return any more data.

What returns is:

{‘code’: 300, ‘message’: ‘The next page token is invalid or expired.’}

I know I’m missing something basic, but I don’t know what it is, and I’m stuck. Any advice would be appreciated.

#################################  
import http.client  
import json

conn = http.client.HTTPSConnection(“[api.zoom.us](http://api.zoom.us)”)  
headers = { ‘authorization’: “Bearer ABC123” } #[changed to generic info for posting purposes]  
conn.request(“GET”, “/v2/metrics/meetings?page\_size=2&to=2020-06-02&from=2020-05-01&type=past”, headers=headers)  
res = conn.getresponse()  
data = res.read()  
dataStr = data.decode(“utf-8”)  
response\_obj = json.loads(dataStr)

for x in response\_obj[‘meetings’]:  
print(x[‘email’])

strNextToken = response\_obj[‘next\_page\_token’]  
print(strNextToken)

# I know this should be a loop, but at this point I can’t even get one more page of data…

if strNextToken:  
conn.request(“GET”, “/v2/metrics/meetings?from=2020-05-01&next\_page\_token=strNextToken&page\_size=30&to=2020-06-02&type=past”, headers=headers)  
res = conn.getresponse()  
data = res.read()  
dataStr = data.decode(“utf-8”)  
response\_obj = json.loads(dataStr)  
#print(data.decode(“utf-8”))  
print(response\_obj)

else:  
print(“No Next Page Token”)  
#################################

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [August 27, 2020, 10:12pm UTC](https://devforum.zoom.us/t/pagination-issue-when-trying-to-loop-through-meetings-with-python/28162/2 "2020-08-27T22:12:44Z")

</div>

Hey @lsteve,

Do you have logs of what you are passing in for the next page token? If you share your next page token we can debug the issue.

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [September 27, 2020, 8:12am UTC](https://devforum.zoom.us/t/pagination-issue-when-trying-to-loop-through-meetings-with-python/28162/3 "2020-09-27T08:12:48Z")

</div>

Closed on September 27, 2020, 8:12am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
