[32788f42] Fix Calendly pagination 400 Bad Request by using native next_page URL

This commit is contained in:
2026-03-21 18:37:03 +00:00
parent 02a1ecb53d
commit d3987ea20b

View File

@@ -78,21 +78,21 @@ def get_calendly_events_raw(api_token: str, start_time: str = None, end_time: st
all_events = []
url = events_url
while url:
response = requests.get(url, headers=headers, params=params)
if url == events_url:
response = requests.get(url, headers=headers, params=params)
else:
response = requests.get(url, headers=headers)
if not response.ok:
raise Exception(f"Calendly API Error: {response.status_code}")
raise Exception(f"Calendly API Error: {response.status_code} - {response.text}")
data = response.json()
all_events.extend(data.get('collection', []))
pagination = data.get('pagination', {})
next_page_token = pagination.get('next_page_token')
if next_page_token:
params = {'user': user_uri, 'count': 100, 'page_token': next_page_token, 'status': 'active'}
else:
url = None
url = pagination.get('next_page') # Use the full URL provided by Calendly
raw_results = []