1

I'm attempting to send a BatchUpdateRequest to the Google Sheets API so that I can delete a row of data from a spreadsheet. My request looks like this:

    var spreadsheetId = '1EV8S8AaAmxF3vP0F6RWxKIUlvF6uFEmsrOFWA1oNBYI';
    var requests = [];
    requests.push({
      "deleteDimension": {
        "range": {
          "sheetId": spreadsheetId,
          "dimension": "ROWS",
          "startIndex": 2,
          "endIndex": 3
        }
      }
    });
    var batchUpdateRequest = {requests: requests}
    var test = auth;
    sheets.spreadsheets.batchUpdate({
      auth: test,
      spreadsheetId: spreadsheetId,
      resource: batchUpdateRequest
    }, function(err, response) {
      if (err) {
        console.log('The API returned an error: ' + err);
        return;
      }
    });

  }

and the error it returns is: The API returned an error: Error: Invalid value at 'requests[0].delete_dimension.range.sheet_id' (TYPE_INT32), "1EV8S8AaAmxF3vP0F6RWxKIUlvF6uFEmsrOFWA1oNBYI"

I've attempted to use the "Try It!" section from google and the "Updating Spreadsheets" section from google to troubleshoot what's happening and I can't figure out if I'm missing something or getting a syntax error.

The error the "Try It" page gives me when I try to test it there gives me this:

{
"error": {
  "code": 400,
  "message": "Invalid JSON payload received. Expected , or ] after array value.\n   \"deleteDimension\": {\n          \"range\n                    ^",
  "status": "INVALID_ARGUMENT"
}
}
Ryan
  • 262
  • 3
  • 19

1 Answers1

3

I think I just goofed on this one. The SheetId variable needs to be given the number after the equal sign in the URL that's after the letters gid. So the number after gid= is what you probably want if you run into an issue like this.

Ryan
  • 262
  • 3
  • 19