0
votes

Trying to update a cell in a Google Sheet with the source attached, I find the error "Invalid value at 'requests[0].update_cells' (oneof), oneof field 'area' is already set. Cannot set 'start'", and I don't know what I am doing wrong

[{
    "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
        }
    }
}]

This is the concrete error:

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

A hint from where can I throw?

EDIT for @Tanaike:

The body of request:

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

and the error of request:

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
Can I ask you about the goal you want? - Tanaike
@Tanaike I want to update the contents of a cell - Miguel García
Thank you for replying. How about removing the property of range and modifying the fields to userEnteredValue? If that modification didn't work, please provide the whole request body for replicating your situation. - Tanaike
@Tanaike for the error I think the range field should be included - Miguel García
Thank you for replying. I apologize for the inconvenience. From your script, "columnIndex"=179 and "rowIndex"=7 are used. This means the cell FX8. So I'm thinking that you want to put the text to the cell FX8. From your error message, it is found that the column length of your sheet is less than 180 columns. So your consideration of I think the range field should be included is not correct. If you want to put the text to the cell FX8, please add the columns. - Tanaike

1 Answers

0
votes

I put the body of the request in case another user encounters the same problem:

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

Thanks to @Tanaike for helping me find the answer