I have this method that is using the java API for writing to the google sheets.
public UpdateCells writeValue(int row, int col, String value)
throws IOException {
List<Request> requests = new ArrayList<Request>();
List<CellData> values = new ArrayList<CellData>();
values.add(new CellData().setUserEnteredValue(new ExtendedValue()
.setStringValue((String) value)));
requests.add(new Request().setUpdateCells(new UpdateCellsRequest()
.setStart(
new GridCoordinate().setSheetId(SheetId)
.setRowIndex(row).setColumnIndex(col))
.setRows(Arrays.asList(new RowData().setValues(values)))
.setFields(
"userEnteredValue,userEnteredFormat.backgroundColor")));
BatchUpdateSpreadsheetRequest batchUpdateRequest = new BatchUpdateSpreadsheetRequest()
.setRequests(requests);
sheetsService.spreadsheets()
.batchUpdate(workSheetId, batchUpdateRequest).execute();
return this;
}
I wrote it some time ago, but I am pretty sure it was working all right. now that I tried to use it again on some other project I am getting a 404 error.
404. That’s an error.
The requested URL
/v4/spreadsheets/:batchUpdatewas not found on this server. That’s all we know.
This is the stacktrace
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1065) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
I used different methods from the google api documentation, but I was getting the same error.
any help is appreciated. Thanks