通过 API 创建分层工作表后,我无法折叠行(通过 API)。这以前有效,但我在我们这边找不到任何明显的错误。此外,我也无法更改这些相同行的背景颜色。
row = smartsheet.models.Row()
row.id = 7151904575098756
row.expanded = False
row.format = ",,,,,,,,,,,,,,,,"
res = smartsheet.Sheets.update_rows(8576857452531588, [row])
如果我执行上述代码,我会从 API 获得成功返回,但返回的 JSON 表示 Expanded 为 true,并且工作表反映了相同的情况。
{"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}]}]}
很好奇是否有人可以阐明这一点。
我已经重现了您所描述的问题 - 但使用原始 JSON 请求,而不是 Python SDK。这表明 API 本身存在问题(不一定是 Python SDK)。
请求动词和端点:
PUT https://api.smartsheet.com/2.0/sheets/2702602705784708/rows
请求正文:
[
{
"id": "198062507724676",
"expanded": false
}
]
请求成功,但响应正文仍然显示设置为
expanded
的 true
属性值 - 尽管请求将其设置为 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": [
...
]
}
]
}
有趣的是:
我注意到,当请求设置的唯一属性是
version
属性时,工作表的 expanded
属性NOT会递增。这表明 Smartsheet 尚未更新工作表。 (任何时候,即使工作表中的单个属性被更新,版本号也会增加。)
如果我更新请求以另外指定要在工作表中更新的单元格值,则该单元格值将更新并且
version
属性值会递增。
此行为似乎表明 API 存在错误 - 即,它忽略了
Update Row(s)请求中的
expanded
属性。我建议您向 Smartsheet 支持人员报告此问题(并包含此 Stack Overflow 帖子的链接)。