Hi,
I am using quicksight API search_dashboards to return dashboards list of my account. However, I found that the NextToken is not null when the last page fetched from the page. Suppose I have 75 dashboards in my quicksight, ideally the 3rd time API call will return the NextToken to null. However, it didn’t. Very appreciate your support.
import boto3
# Replace 'your_aws_region' with your AWS region
aws_region = 'us-east-1'
# Create a Boto3 QuickSight client
quicksight_client = boto3.client('quicksight', region_name=aws_region)
def list_quicksight_dashboards():
try:
# List dashboards
response = quicksight_client.search_dashboards(
AwsAccountId='123',
Filters=[
{
'Operator': 'StringEquals',
'Name': 'QUICKSIGHT_USER',
'Value': 'abc123'
},
],
MaxResults=25,
)
# Print information about each dashboard
print("total dashboards: ", len(response["DashboardSummaryList"]))
while response.get("NextToken"):
response = quicksight_client.search_dashboards(
AwsAccountId='123',
Filters=[
{
'Operator': 'StringEquals',
'Name': 'QUICKSIGHT_USER',
'Value': 'abc123'
},
],
MaxResults=25,
NextToken=response["NextToken"]
)
print("total dashboards: ", len(response["DashboardSummaryList"]))
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
list_quicksight_dashboards()
>>>> output:
total dashboards: 25
total dashboards: 25
total dashboards: 25
total dashboards: 0