From 81f3f2cc83f5e8b1e71347330ca59b24a12d4d48 Mon Sep 17 00:00:00 2001 From: Nora Date: Fri, 3 Jul 2026 17:07:40 -0600 Subject: [PATCH] fix(smartsheet): send addRow body as top-level array, not { rows: [...] } MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Smartsheet's POST /sheets/{id}/rows expects the body to be a top-level JSON array (or a single Row object), NOT wrapped in { rows: [...] }. When we wrapped the body, Smartsheet returned: - HTTP 200 OK - resultCode: 0 - message: 'SUCCESS' …and silently dropped every cell value, creating an empty row. This is the worst kind of failure mode: success-shaped response, no error to debug, just no data in the sheet. (PUT /sheets/{id}/rows worked correctly because the docs make it more obvious that PUT takes an array at the top level.) Root cause confirmed by direct API probe: - Body: { rows: [{ cells: [...] }] } → 200, no values persisted - Body: [{ cells: [...] }] → 200, values persisted Fix: send the array directly as the request body. After deploy, retries against the 25 queued entries will: 1. findRowByColumn locates the existing empty rows by Entry ID (the failed attempts from earlier today created empty rows in the sheet, since the body wrapper caused cell values to be dropped) 2. No duplicate insert; the existing empty row is reused 3. Queue marked as synced with smartsheetRowId The user should also manually delete the empty orphan rows from their sheet (rows 27-38 from the failed syncs + my probes). Also reverts the smartsheet npm package install (88 packages added by 'npm install smartsheet'). The REST fix is one line; the SDK's deps weren't worth keeping. --- src/lib/smartsheet.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) 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;