I have to write more than 1000 rows into a Google sheet, therefore I need to increase the number of rows (I got the Google.Apis.Requests.RequestError when I attempted to write 4640 rows).
Searching the Stack Overflow website resulted in information telling me that I needed to use UpdateSheetPropertiesRequest or InsertDimensionRequest and create a new request that could be in the same Spreadsheets.BatchUpdate call.
In line with a Python example on Stack Overflow, I set the properties of the InsertDimensionRequest instance and included them in my existing code (= publicly available C# code by Ian Preston).
The code then looks like this:
public void AddCells(GoogleSheetParameters googleSheetParameters, List<GoogleSheetRow> rows)
{
var requests = new BatchUpdateSpreadsheetRequest { Requests = new List<Request>() }; //Existing code
int sheetId = GetSheetId(_sheetsService, _spreadsheetId, googleSheetParameters.SheetName); //Existing code
InsertDimensionRequest insertDimensionRequest = new InsertDimensionRequest(); //Added code
insertDimensionRequest.Range.SheetId = sheetId; //Added code
insertDimensionRequest.Range.Dimension = "ROWS"; //Added code
insertDimensionRequest.Range.StartIndex = 999; //Added code
insertDimensionRequest.Range.EndIndex = 6999; //Added code
insertDimensionRequest.InheritFromBefore = false; //Added code
var request = new Request { UpdateCells = new UpdateCellsRequest { Start = gc, Fields = "*" } }; //Existing code
//some code here
var request1 = new Request { ???????? }; //code to be added - how should the request look like?
requests.Requests.Add(request); //Existing code
requests.Requests.Add(request1); //Added code
}
But I do not know how a new request can be created in C#.
My question is: How to create such an request (named as request1 in my code)?