Does anyone have a good C# example for updating a cell with the v4 API?
I have the get cell values c# example from the developer website working with Google Sheets A
For anyone else that finds this thread. I got the exception below:
Exception Details: Google.GoogleApiException: Google.Apis.Requests.RequestError 'valueInputOption' is required but not specified [400] Errors [ Message['valueInputOption' is required but not specified] Location[ - ] Reason[badRequest] Domain[global]]
Solved with:
SpreadsheetsResource.ValuesResource.UpdateRequest update = service.Spreadsheets.Values.Update(valueRange, spreadsheetId2, range2);
update.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
UpdateValuesResponse result2 = update.Execute();
Source:
https://stackoverflow.com/a/38841369/3850405
However this caused my data to get a single quote (') before the value I entered, like this:
After reading the documentation I saw that the examples used "valueInputOption": "USER_ENTERED":
https://developers.google.com/sheets/api/samples/writing#write_to_multiple_ranges
After switching to ValueInputOptionEnum.USERENTERED everything worked as expected.
updateRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;