get_report in Python API not returning all rows when no page / pagesize specified

Options

I don't think I used to run into this issues but when using the Python SDK I'm getting an index out of range when looping though the report object returned by get_report when it is called without a page and pageSize:

Example code:

# Modules
import sys
import smartsheet
import pprint


#static details
SourceReportID = #############  # is the the ID of the report in smartsheet where data is being pulled from


#Establish authentication for smartsheet
accessToken = "xxxxxxxxxxxxxx" # this is where the accessToken from smartsheet is entered
ssClient = smartsheet.Smartsheet(accessToken)

# get report object
ssReportObj = ssClient.Reports.get_report(SourceReportID)


# loop though rows of report
for x in range(ssReportObj.total_row_count):
    # create an empty dictionary
    MyDict = {}
    # for each column in row
    for y in range(len(ssReportObj.columns)):
        # create key value pair on column title and cell value for BDS
        MyDict[ssReportObj.columns[y].title] = str(ssReportObj.rows[x].cells[y].value)
    pprint.pprint(MyDict)


when x hits 100 it gives an index out of range error

The documentation https://smartsheet.redoc.ly/#operation/getReport says:


Best Answer

  • Genevieve P.
    Genevieve P. Employee Admin
    Answer ✓
    Options

    Hi @Ryfrank

    You are correct that the default is 100, which is why you're receiving the error. The default is set to 100 even if no pageSize or page is specified: I would recommend setting paging into your request.

    I will also submit feedback to the documentation team that there's an additional sentence in the pageSize text that's incorrect, thank you! (You can see it talks about returning rows from a Sheet, but this request is for a Report).

    Cheers,

    Genevieve

Answers

  • Genevieve P.
    Genevieve P. Employee Admin
    Answer ✓
    Options

    Hi @Ryfrank

    You are correct that the default is 100, which is why you're receiving the error. The default is set to 100 even if no pageSize or page is specified: I would recommend setting paging into your request.

    I will also submit feedback to the documentation team that there's an additional sentence in the pageSize text that's incorrect, thank you! (You can see it talks about returning rows from a Sheet, but this request is for a Report).

    Cheers,

    Genevieve