I'm trying to delete a single row with the Google Sheets API in C#, and I can't get it to work. Fetching and updating rows work as intended.
Here's my code (inspired from C# Google Sheets API - Delete Row and the Java documentation):
var request = new Request
{
DeleteDimension = new DeleteDimensionRequest
{
Range = new DimensionRange
{
SheetId = 0,
Dimension = "ROWS",
StartIndex = 21,
EndIndex = 21
}
}
};
var deleteRequest = new BatchUpdateSpreadsheetRequest {Requests = new List<Request> {request}};
// First way: create a batch update request from scratch then execute it
var responseFirstWay = new SpreadsheetsResource.BatchUpdateRequest(MY_SHEETS_SERVICE, deleteRequest, MY_SPREADSHEET_ID).Execute();
// Second way: create a batch update request from the existing SheetsService then execute it
var responseSecondWay = MY_SHEETS_SERVICE.Spreadsheets.BatchUpdate(deleteRequest, MY_SPREADSHEET_ID).Execute();
I've tried with various indexes, but it doesn't seem to change anything (in my example above I've put 21, with all rows up to 30 filled with data). I find a bit weird to have a SheetId set to zero, but that's the gid parameter I have when visiting Google Sheets.
No matter how I create my BatchUpdateRequest, the response is empty after I execute it.