fix(smartsheet): send addRow body as top-level array, not { rows: [...] }
Deploy to route.crispygoat.com / deploy (push) Successful in 3m57s
Deploy to route.crispygoat.com / deploy (push) Successful in 3m57s
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.
This commit is contained in:
@@ -297,8 +297,15 @@ export async function addRow(
|
||||
"POST",
|
||||
`/2.0/sheets/${encodeURIComponent(sheetId)}/rows`,
|
||||
token,
|
||||
{
|
||||
rows: [
|
||||
// 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),
|
||||
@@ -306,7 +313,6 @@ export async function addRow(
|
||||
})),
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
|
||||
const result = data?.result;
|
||||
|
||||
Reference in New Issue
Block a user