更新单元格Google Sheet API

时间:2019-09-16 18:51:16

标签: google-sheets-api

尝试更新带有附加源的Google表格中的单元格,我发现错误“在'requests [0] .update_cells'(oneof)处无效值,oneof字段'area'已设置。无法设置'start '”,我不知道我在做什么错

[{
    "updateCells"={
        "fields"="totalUpdatedCells", 
        "range"={
            "endColumnIndex"=179, 
            "endRowIndex"=7, 
            "sheetId"=XXXXX, 
            "startColumnIndex"=179, 
            "startRowIndex"=7
        }, 
        "rows"=[
            {
                "values"=[
                    {
                        "userEnteredValue"={
                            "stringValue"="My text"
                        }
                    }
                ]
            }
        ], 
        "start"={
            "columnIndex"=179, 
            "rowIndex"=7, 
            "sheetId"=XXXXX
        }
    }
}]

这是具体错误:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid value at 'requests[0].update_cells' (oneof), oneof field 'area' is already set. Cannot set 'start'",
    "reason" : "badRequest"
  } ],
  "message" : "Invalid value at 'requests[0].update_cells' (oneof), oneof field 'area' is already set. Cannot set 'start'",
  "status" : "INVALID_ARGUMENT"
}

从哪里可以扔出一条提示?

编辑@Tanaike:

请求正文:

{
   "requests"=   [
      {
         "updateCells"= {
            "fields"="userEnteredValue",
            "rows"= [
               {
                  "values"= [
                     {
                        "userEnteredValue"= {
                           "stringValue"="My text"
                        }
                     }
                  ]
               }
            ],
            "start"=            {
               "columnIndex"=179,
               "rowIndex"=7,
               "sheetId"=XXXXX
            }
         }
      }
   ]
}

和请求错误:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid requests[0].updateCells: GridCoordinate.columnIndex[179] is after last column in grid[25]",
    "reason" : "badRequest"
  } ],
  "message" : "Invalid requests[0].updateCells: GridCoordinate.columnIndex[179] is after last column in grid[25]",
  "status" : "INVALID_ARGUMENT"
}

1 个答案:

答案 0 :(得分:0)

我放置了请求的正文,以防其他用户遇到相同的问题:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
  <bindingRedirect oldVersion="0.0.0.0-2.10.0.0" newVersion="2.10.0.0"/>
</dependentAssembly>

感谢@Tanaike帮助我找到答案