Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: adding rows with smartsheet API

I can't seem to get a add row(s) to work. I get the following error, but I believe the data is formatted correctly. Thanks in advance!

{"errorCode":1008,"message":"Unable to parse request. The following error occurred: Request body must be either a JSON object or JSON array."}

POST https://api.smartsheet.com/1.1/sheet/{sheetId}/rows

ContentType=application/json

[
  {
   "toBottom" : true, 
   "cells" : [
        {"columnId" : "328984295696260", "value" : 888.0},
        {"columnId" : 4832583923066756, "value" : 100.0}
    ]
  },
  {
   "toBottom" : true, 
   "cells": [
      {"columnId" : "328984295696260", "value" : 999.0},
      {"columnId" : 4832583923066756, "value" : 100.0}
    ]
   }
]
like image 875
itsallgood Avatar asked Aug 05 '26 00:08

itsallgood


1 Answers

Looks like you've encountered a bug with the API 1.1 "Add Row(s)" endpoint. I get the same error as you report when attempting a similar request using the API 1.1 endpoint -- but it works fine with the API 2.0 endpoint.

I'd suggest that you try using the API 2.0 "Add Row(s)" endpoint instead:

POST https://api.smartsheet.com/2.0/sheets/{sheetId}/rows

API 1.1 has been deprecated (see announcement here), so you should be using API 2.0 for any new API development. The API 2.0 documentation can be found here.

PS - for good measure (although it's not the cause of your issue) -- I'd suggest that you remove quotation marks from around the first numerical columnId value in each cells collection, as they're not necessary.

like image 174
Kim Brandl Avatar answered Aug 08 '26 14:08

Kim Brandl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!