"Invalid requests[0].updateCells: Invalid field" when using barchUpdate on googlespreadsheet API

  google-sheets, google-sheets-api, php
$range1 = new Google_Service_Sheets_GridRange();
$range1->setStartRowIndex(92);
$range1->setEndRowIndex(92);
$range1->setStartColumnIndex(4);
$range1->setEndColumnIndex(4);
$range1->setSheetId(1433074761);

$range2 = new Google_Service_Sheets_GridRange();
$range2->setStartRowIndex(92);
$range2->setEndRowIndex(92);
$range2->setStartColumnIndex(2);
$range2->setEndColumnIndex(2);
$range2->setSheetId(1433074761);

$request1 = new Google_Service_Sheets_UpdateCellsRequest();
$request1->setFields('aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
$request1->setRange($range1);
$body1 = new Google_Service_Sheets_Request();
$body1->setUpdateCells($request1);



$request2 = new Google_Service_Sheets_UpdateCellsRequest();
$request2->setFields('aaaaaaaaaaaaaaaaaaaaaaaaaaa');
$request2->setRange($range2);
$body2 = new Google_Service_Sheets_Request();
$body2->setUpdateCells($request2);

$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest();
$batchUpdateRequest->setRequests([$body1, $body2]);

So I was able to fix an error I had, but now I am getting an error for the field entered through the setFields method. I thought you could put any string, but it seems that it’s not the case at all. The documentation doesn’t seem to provide what might be the issue.

I get the error:

Fatal error: Uncaught GoogleServiceException: {
  "error": {
    "code": 400,
    "message": "Invalid requests[0].updateCells: Invalid field: aaaaaaaaaaaaaaaa
aaaaaaaaaaaa",
    "errors": [
      {
        "message": "Invalid requests[0].updateCells: Invalid field: aaaaaaaaaaaa
aaaaaaaaaaaaaaaa",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

https://developers.google.com/resources/api-libraries/documentation/sheets/v4/php/latest/class-Google_Service_Sheets_GridRange.html

The documentation itself says that the parameter can be mixed, so can be anything, but it doesn’t seem to work.

https://php.watch/versions/8.0/mixed-type

Source: Ask PHP

LEAVE A COMMENT