Reputation: 258
I've been able to read sheets, rows, columns, and cells using the Python SDK for Smartsheet, but I haven't been able to actually change/write/update a cell value. I've simplified my code quite a bit and I'm left with this:
import smartsheet
MySS = smartsheet.Smartsheet(MyApiKey)
single_row = MySS.Sheets.get_row(SHEET_ID, ROW_ID)
destination_cell = single_row.get_column(DST_COLUMN_ID)
destination_cell.value = "new value"
single_row.set_column(destination_cell.column_id, destination_cell)
MySS.Sheets.update_rows(SHEET_ID, ROW_ID)
I get the following error when I run this code:
Traceback (most recent call last):
File "C:/Users/XXXXXX/Python/Smartsheet/test.py", line 24, in <module>
MySS.Sheets.update_rows(SHEET_ID, ROW_ID)
File "C:\Users\XXXXXX\Python\virtualenv PC Smartsheet\lib\site-packages\smartsheet\sheets.py", line 961, in update_rows
for item in _op['json']:
TypeError: 'long' object is not iterable
I have tried passing the ROW_ID in the last line of code as ROW_ID
and [ROW_ID]
and [ROW_ID,]
but get the same error nonetheless.
I'm using this as my reference: http://smartsheet-platform.github.io/api-docs/?python#update-row(s)
What am I doing wrong?
Upvotes: 2
Views: 1096
Reputation: 1719
You're so close! Rather than sending the ROW_ID
to the update_rows()
you actually want to send the row
object in a list.
So, in your case, you would just want to change your last line to be
MySS.Sheets.update_rows(SHEET_ID, [single_row])
Upvotes: 4