I'm not kidding when I say I've spent 8+ hours on this. I'm no programmer so ChatGPT has been pretending to fix it for me, unsuccessfully. I have the problem narrowed down to the JSON output. ChatGPT keeps asking me to update my code and the HTTP Request body in various ways without much change. You'd think this would be something it would excel in, but it's not :p.
Can someone please help me modify my script and/or the HTTP Request Body I'm using so that it works properly?
The problem is with my Call API that is trying to write the data I have to the sheet in the wrong JSON format. Update sheet Documentation is here
API Log:
"Required object attribute(s) are missing from your request: row.id."
Javascript Output:
[{"cells":[{"columnId":4090595125186439,"value":"en_US"},{"columnId":6564779755523975,"value":"US/Eastern"},{"columnId":284369337667462,"value":false},{"columnId":8447143662276584,"value":false},{"columnId":7039768778722204,"value":false},{"columnId":2536169151352758,"value":false}],"id":8400433777348481}]
I even added a "String tools: Compose Text" to see what output it's sending. that's below:
"{\n "rows": {"result":[{"cells":[{"columnId":4090595125186439,"value":"en_US"},{"columnId":6564779755523975,"value":"US/Eastern"},{"columnId":284369337667462,"value":false},{"columnId":8447143662276584,"value":false},{"columnId":7039768778722204,"value":false},{"columnId":2536169151352758,"value":false}],"id":8400433777348481}]}\n}\n"
Entire log:
Java element: (the only value you cannot see is {{states.startstate.call_api.make_api_call.response}} )
Javascript Code:
/*************************************************************************
Build Row Update Payload – returns a plain array of row update objects
*************************************************************************/
// 1) Validate inputs
if (!user || typeof rowId === 'undefined') {
throw new Error("Missing user or rowId");
}
if (!Array.isArray(columns)) {
throw new Error(columns is not an array (got ${typeof columns}));
}
// 2) Map column titles → IDs
const colMap = new Map(columns.map(c => [c.title, c.id]));
// 3) Collect non-empty cells
const cells = [];
function setCell(title, value) {
if (value != null && value !== "") {
cells.push({ columnId: colMap.get(title), value });
}
}
// 4) Populate enrichment fields
setCell("Company", user.company);
setCell("Department", user.department);
setCell("Title", user.title);
setCell("Locale", user.locale);
setCell("Role", user.role);
setCell("Timezone", user.timeZone);
setCell("Office Phone", user.workPhone);
setCell("Mobile Phone", user.mobilePhone);
setCell("Admin", !!user.admin);
setCell("Group Admin", !!user.groupAdmin);
setCell("Licensed", !!user.licensedSheetCreator);
setCell("Resource Viewer",!!user.resourceViewer);
// 5) Return a plain array of update objects (required format)
return [
{
id: Number(rowId), // Smartsheet requires numeric ID
cells
}
];
I'm simply trying to write the user details to the sheet using the API but it doesn't recognize the format I'm sending it in.
@SSFeatures this seems right up your alley if nobody else responds.