Search code examples
smartsheet-api

Trying to insert rows with smartsheet-api and php


I am able to update a row easily, but for the life of me can't get a new row inserted. Here's my data:

{
    "toTop":true,
    "cells": [
        {
            "columnId": 5830169266022276,
            "value": true
        },
        {
            "columnId": 5830169266022276,
            "value": "New status",
            "strict": false
        }
    ]
},
{
    "toTop":true,
    "cells": [
        {
            "columnId": 5830169266022276,
            "value": true
        },
        {
            "columnId": 5830169266022276,
            "value": "New status",
            "strict": false
        }
    ]
}

The error I get is:

Required object attribute(s) are missing from your request: id.

Help, please!


Solution

  • Based on that error message, I'd suspect that perhaps you're trying to use the verb PUT on your "Add Row" request. (If you're sending PUT, then Smartsheet thinks you want to update a row and therefore requires that you specify the id of the row.) The command to Add a Row should use the verb POST:

    POST /sheets/(sheetId}/rows

    Also, I notice that you're specifying the same cell (i.e., columnId) twice for each row. This might be problematic as well. Each row object should contain cell objects corresponding to columns that you want to update in that row -- and columnId value should not be repeated/duplicated within a given row.