SmartSheet在python SDK中将行添加到底部

时间:2018-12-05 06:43:45

标签: python smartsheet-api

使用python库和2.0 API文档。我正在尝试添加一行,但始终收到错误:"message": "Required object attribute(s) are missing from your request: row.id."

问题似乎出在new_row.to_bottom=True语句上。我是否理解不正确或API中有错误? 我还注意到,当我在同一通话中添加to_top时,消息以only toTop or toBottom in a single call.的形式返回,我再次尝试使用该语法,但仍然没有运气。

import smartsheet
...
new_row = ss_client.models.Row()
new_row.to_bottom = True       #also tried .toBottom=True
new_cell = ss_client.models.Cell()
new_cell.column_id = 9380123454964
new_cell.value = 'update'
new_cell.strict = False
new_row.cells.append(new_cell)
updated_row = ss_client.Sheets.update_rows(1234567,[new_row]) #also tried new_row outside of []


Response: {
status: 400 Bad Request
content: {
{
    "detail": {
        "index": 0
    },
    "errorCode": 1012,
    "message": "Required object attribute(s) are missing from your request: row.id.",
    "refId": "152g54q6e89sd"
}
}

有人知道如何解决此问题吗? SDK仍在1.0上吗?

1 个答案:

答案 0 :(得分:2)

您正在尝试更新尚不存在的行。在实际创建行之前,您不知道行ID是什么,因为服务器尚未为其分配行ID。将userModel.updateUser({_id: userId, name:name},{$set:{data:data}}, (err, result) => { console.log(err, result); }); 替换为update_rows

add_rows