Python SDK 400 error on bot intents pagination

Hey, sorry for the basic question. Pulling intents from the staging bot with genesyscloud Python SDK (v2.1.0) is doing jack all after the first page. The initial request returns 25 records without issue. Second loop iteration throws a 400. Read that community thread about continuation tokens expiring in 15 minutes, but the script finishes in under 30 seconds, so it’s not a timeout issue.

Here’s the snippet causing trouble:

from genesyscloud import BotApi
from genesyscloud.auth import OAuth2Client

oauth = OAuth2Client(client_id=env.CLIENT_ID, client_secret=env.CLIENT_SECRET)
oauth.login()
bot_api = BotApi()
bot_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"

response = bot_api.get_bot_intents(bot_id, page_size=25)
print(response.page_size)

while response.next_page_token:
 response = bot_api.get_bot_intents(bot_id, page_size=25, continuation_token=response.next_page_token)

Logs show a 400 immediately. Console stays empty except for the traceback. The SDK does have a built-in helper, but the custom filter requirement means it won’t work for us. That community post suggested passing continuation_token as a keyword argument. SDK documentation points to next_page_token. Swapping the parameter name just breaks the method signature entirely.

[screenshot of the 400 payload attached]
Payload claims the token is malformed. OAuth2 refresh cycle might be interfering. Request headers look identical in Postman, but Postman handles the auth flow differently. Can’t figure out if the token format changed in the latest staging update. Staring at this for two hours and it’s probably something stupid.

{
 "code": "invalid.continuation.token",
 "message": "The continuation token provided is invalid or expired.",
 "status": 400
}
params = {'pageSize': 25, 'continuation_token': resp.body.get('continuation_token')}
intents = api.get_bot_intents(**params)

API docs state the Python client strips continuation tokens on retry. You’ll need to inject it directly into the kwargs. Does the staging bot route through custom intent categories? Default NLU endpoints handle pagination differently.

1 Like