You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

使用Smartsheet add_rows API添加带位置指定多行的请求格式问题

Power Automate调用Smartsheet Add Rows API的问题修复

需求

一次性添加两行数据,每行分别放到指定parentId对应的父行底部。

错误请求配置(Power Automate中)

{
    "uri": "https://api.smartsheet.com/2.0/sheets/<sheetID>/rows",
    "method": "POST",
    "headers": {
        "Authorization": "*sanitized*",
        "Content-Type": "application/json"
    },
    "body": [
        {
            "rows": [
                {
                    "parentId": 3549566531080068,
                    "toBottom": true,
                    "cells": [
                        {
                            "columnId": 5365531952238468,
                            "value": "test1"
                        },
                        {
                            "columnId": 7617331765923716,
                            "objectValue": {
                                "objectType": "MULTI_PICKLIST",
                                "values": [
                                    "team1",
                                    "team2"
                                ]
                            }
                        }
                    ]
                },
                {
                    "parentId": 3865014262894468,
                    "toBottom": true,
                    "cells": [
                        {
                            "columnId": 5365531952238468,
                            "value": "Test"
                        }
                    ]
                }
            ]
        }
    ]
}

问题现象

  • 响应仅返回一行添加成功的记录
  • 指定的parentId位置被忽略,行被添加到工作表最底部
  • 目标列未填充任何数据

响应内容

{
    "statusCode": 200,
    "headers": {
        ...
    },
    "body": {
        "message": "SUCCESS",
        "resultCode": 0,
        "version": 93,
        "result": [
            {
                "id": xxxxxxx,
                "sheetId": xxxxxxx,
                "rowNumber": 133,      // 此处为工作表底部,指定的parentId对应行约为101行
                "siblingId": 8611906339278724,
                "expanded": true,
                "locked": false,
                "lockedForUser": false,
                "createdAt": "2025-10-21T21:52:08Z",
                "modifiedAt": "2025-10-21T21:52:08Z",
                "cells": [
                    { "columnId": 963702111817604 },
                    { "columnId": 4931695829274500 },
                    { "columnId": 8801951526113156 },
                    { "columnId": 216964736438148 },
                    { "columnId": 5365531952238468 },
                    { "columnId": 6649929574076292 },
                    { "columnId": 2146329946705796 },
                    { "columnId": 4028693853458308 },
                    { "columnId": 3113732138553220 },
                    { "columnId": 7617331765923716 },
                    { "columnId": 1987832231710596 },
                    { "columnId": 7775829480918916 },
                    { "columnId": 4398129760391044 },
                    { "columnId": 8901729387761540 },
                    { "columnId": 105636365553540 },
                    { "columnId": 6420724013813636 }
                ]
            }
        ]
    }
}

已完成排查

  • 确认所有parentId均有效存在
  • 确认所有columnId均有效存在
  • 单独添加一行且不额外包裹数组时,请求可正常执行
  • 检查Smartsheet工作表,确认数据未实际更新

正确请求格式

问题核心是请求体结构错误:原请求中body被包裹成了数组,且多了一层不必要的嵌套。Smartsheet Add Rows API要求请求体是一个包含rows数组的对象,而非数组包裹的对象。

修正后的Power Automate请求配置:

{
    "uri": "https://api.smartsheet.com/2.0/sheets/<sheetID>/rows",
    "method": "POST",
    "headers": {
        "Authorization": "*sanitized*",
        "Content-Type": "application/json"
    },
    "body": {
        "rows": [
            {
                "parentId": 3549566531080068,
                "toBottom": true,
                "cells": [
                    {
                        "columnId": 5365531952238468,
                        "value": "test1"
                    },
                    {
                        "columnId": 7617331765923716,
                        "objectValue": {
                            "objectType": "MULTI_PICKLIST",
                            "values": [
                                "team1",
                                "team2"
                            ]
                        }
                    }
                ]
            },
            {
                "parentId": 3865014262894468,
                "toBottom": true,
                "cells": [
                    {
                        "columnId": 5365531952238468,
                        "value": "Test"
                    }
                ]
            }
        ]
    }
}

关键修正点

  • 去掉body外层的数组包裹,直接使用{"rows": [...]}作为请求体
  • 保留每个row对象中的parentIdtoBottom参数,确保行插入到指定父行底部
  • 保持cells结构不变,确保columnId和对应值(或objectValue)正确传递

内容的提问来源于stack exchange,提问作者WaqarQureshii

火山引擎 最新活动