Search code examples
smartsheet-api

Smartsheet API get_sheet (Python) filters not working


I'm using Python 3.52 , Smartsheet API SDK 2.0.10.

The get_sheet (in sheets.py) has three 'filters' which are lists of integers for

  1. row_numbers,
  2. column_ids, and
  3. row_ids.

I can get none of them to work, together or separately. For example,

row_numbers = [2, 13]
sheet = smartsheet.Sheets.get_sheet(sheet_id, row_numbers)
for row in sheet.rows:
    print(row.row_number)

returns all of the rows, not just 2 and 13. Am I doing something wrong or is this a bug?

Craig


Solution

  • Reputation won't let me comment yet, but Steve W is on the right track.

    See https://docs.python.org/3/reference/expressions.html#calls for a description of how Python assigns arguments to parameters list. In your example row_numbers is being assigned to the include parameter. To do what you want you'll have to use a combination of positional(sheet_id) and keyword(row_numbers) arguments. All other arguments will use defaults as specified by function definition.

    This code works as expected, returning the 2nd and 13th rows in the sheet:

    row_numbers=[2,13]
    sheet = smartsheet.Sheets.get_sheet(sheet_id, row_numbers=row_numbers)