1

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/:batchUpdate was 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

4
  • Does this question apply? stackoverflow.com/questions/29833473/… Commented Aug 28, 2018 at 14:24
  • @tehhowch Thanks. it might,but I think i followed the official google documentation on java but that didnt work either! Commented Aug 29, 2018 at 7:42
  • @SkarosIlias any luck with this issue? I'm having the same issue and I suspect it's because I'm trying to persist my sheetService. Commented Aug 28, 2019 at 2:25
  • @Proximo to be honest I dont even remember. I see that I still have that code on my application, but havent used that for ages. not sure if it even works. sorry Commented Aug 28, 2019 at 12:38

1 Answer 1

2

Okay I figured this out.

If your spreadsheetId is invalid then you'll receive a 404 since the spreadsheetId is part of the URL.

So double-check that your spreadsheetId is correct and not being nulled about by a process like was the case for me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.