"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