Reputation: 516
After creating a hierarchical sheet via the API, I'm unable to get the rows to collapse (via the API). This worked before, but I can't find any clear error on our end. In addition, I'm also unable to change the background color of these same rows.
row = smartsheet.models.Row()
row.id = 7151904575098756
row.expanded = False
row.format = ",,,,,,,,,,,,,,,,"
res = smartsheet.Sheets.update_rows(8576857452531588, [row])
If I execute the above, I get a success back from the API, but the JSON coming back says expanded is true, and the sheet reflects the same.
{"message":"SUCCESS","resultCode":0,"version":37,"failedItems":[],"result":[{"id":7151904575098756,"rowNumber":2,"siblingId":2648304947728260,"expanded":true,"locked":false,"lockedForUser":false,"createdAt":"2024-04-17T21:52:42Z","modifiedAt":"2024-04-17T22:30:42Z","cells":[{"columnId":4075357035515780,"value":"2023-10-24"},{"columnId":8578956662886276,"displayValue":"3 Weekday","value":"3 Weekday"},{"columnId":416182338277252,"displayValue":"08:37:00","value":"08:37:00"},{"columnId":4919781965647748,"displayValue":"661","value":"661"},{"columnId":2667982151962500,"displayValue":"3","value":3.0},{"columnId":7171581779332996,"displayValue":"3","value":3.0},{"columnId":1542082245119876,"displayValue":"0","value":0.0},{"columnId":6045681872490372,"displayValue":"0","value":0.0},{"columnId":3793882058805124,"displayValue":"1","value":1.0},{"columnId":8297481686175620,"displayValue":"0","value":0.0},{"columnId":979132291698564},{"columnId":5482731919069060},{"columnId":3230932105383812,"displayValue":"21492.12","value":21492.120000000003},{"columnId":7734531732754308,"displayValue":"-4824.36","value":-4824.360000000001},{"columnId":2105032198541188,"displayValue":"-1.22447","value":-1.2244711084806896}]}]}
Curious if anyone can shed any light on this.
Upvotes: 0
Views: 60
Reputation: 13480
I've reproduced the issue you've described -- but using a raw JSON request, instead of the Python SDK. This points to a problem with the API itself (not necessarily the Python SDK).
Request verb and endpoint:
PUT https://api.smartsheet.com/2.0/sheets/2702602705784708/rows
Request body:
[
{
"id": "198062507724676",
"expanded": false
}
]
Request is successful, but response body still shows the expanded
property value set to true
-- despite the fact that the request set it to false
.
{
"message": "SUCCESS",
"resultCode": 0,
"version": 63,
"failedItems": [],
"result": [
{
"id": 198062507724676,
"rowNumber": 1,
"expanded": true,
"locked": false,
"lockedForUser": false,
"createdAt": "2024-04-20T23:09:59Z",
"modifiedAt": "2024-04-20T23:30:27Z",
"cells": [
...
]
}
]
}
Interestingly:
I notice that the version
property of the sheet is NOT being incremented when the only property the request sets is the expanded
property. This indicates that Smartsheet has not updated the sheet. (Any time even a single property within a sheet is updated, version number will increment.)
If I update my request to additionally specify a cell value to update within the sheet, then the cell value is updated AND the version
property value IS incremented.
This behavior seems to indicate a bug with the API -- i.e., it's ignoring the expanded
property in an Update Row(s) request. I'd suggest you report this problem to Smartsheet support (and include a link to this Stack Overflow post).
Upvotes: 2