Error: adding rows with smartsheet API

丶灬走出姿态 提交于 2019-12-22 10:55:26

问题


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}
    ]
   }
]

回答1:


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.



来源:https://stackoverflow.com/questions/33684125/error-adding-rows-with-smartsheet-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!