diff --git a/src/lib/smartsheet.ts b/src/lib/smartsheet.ts index f973095..02d2c55 100644 --- a/src/lib/smartsheet.ts +++ b/src/lib/smartsheet.ts @@ -297,16 +297,22 @@ export async function addRow( "POST", `/2.0/sheets/${encodeURIComponent(sheetId)}/rows`, token, - { - rows: [ - { - cells: cells.map((c) => ({ - columnId: Number(c.columnId), - value: toCellValue(c.value), - })), - }, - ], - }, + // Body MUST be a top-level array (or single Row object), NOT wrapped + // in { rows: [...] }. When wrapped, Smartsheet returns HTTP 200 + + // resultCode 0 + "SUCCESS" but silently drops every cell value — + // creates empty rows. (Verified by direct probe: POSTing with + // { rows: [...] } returns 200 with no values persisted; POSTing with + // [...] returns 200 with values persisted.) This was the root cause + // of "rows created but data not inserted" — see the Smartsheet docs + // cURL example for POST /sheets/{id}/rows. + [ + { + cells: cells.map((c) => ({ + columnId: Number(c.columnId), + value: toCellValue(c.value), + })), + }, + ], ); const result = data?.result;