"errorCode" : 1008 | Adding new new row using powershell

I am using powershell to automate smartsheet entries, I am able fetch sheet data but I am facing issues while adding a new row to the smartsheet.

$headers = @{

   'Authorization' = 'Bearer <API token>'

  'Content-Type'  = 'application/json'

}

$body = @{

  'columnId ' = '229799331424132'

  'value'   = 'true'

}

$puturi="https://api.smartsheet.com/2.0/sheets/7647453991200644/rows"

Invoke-RestMethod -Method post -Uri $puturi -Headers $headers -Body $body

using this API reference guide:


ERROR:

Invoke-RestMethod : {

 "errorCode" : 1008,

 "message" : "Unable to parse request. The following error occurred: Unrecognized token 'value': was expecting ('true', 'false' or 'null')\n at [Source: REST input; line: 1, 

column: 7]",

 "refId" : "1aipur5vacxtg"

}

At line:1 char:1

Answers

  • Hi @kashif.raza

    Is that column a checkbox column? If so, try removing out the quotes from around the True value:

    }

    $body = @{

      'columnId ' = '229799331424132'

      'value'   = true

    }


    Let me know if this works for you!

    Cheers,

    Genevieve

    Need more information? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao!👋 | Global Discussions

  • I tried it but but it is not working and surprisingly column is not a checkbox that is a text colume and I tried this also.


    $body = @{

      'columnId ' = '229799331424132'

      'value'   = "My text String"

    }

  • Hi @kashif.raza

    If you're updating a Text/Number cell with a text value via the API, then yes, wrapping it in quotes is the correct syntax.

    The error message expecting ('true', 'false' or 'null') sounds to me like the column is expecting a boolean value (e.g. a checkbox column, or flag or star symbol). I'm unable to replicate that error with a Text/Number column.

    That said, I am using the API directly and have not worked with PowerShell. I would suggest posting in the Power Shell Tech Community for help with Power Shell syntax.

    Thanks!

    Genevieve

    Need more information? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao!👋 | Global Discussions