Take the 2-minute tour ×

I'm trying to edit a gdocs spreadsheet using the GData API. I have the following code:

    _service = new DocsService("attask-gdocsintegration-1.0");
    _service.setUserCredentials(username, password);

    String feedUrl = "https://docs.google.com/feeds/default/private/full";

    SpreadsheetQuery query = new SpreadsheetQuery(new URL(feedUrl));
    SpreadsheetFeed feed = _service.getFeed(query, SpreadsheetFeed.class);

    if(feed.getEntries().size() != 1) {
        throw new FileNotFoundException("'"+title+"' not a spreadsheet");
    _entry = feed.getEntries().get(0);
    List<WorksheetEntry> worksheets = _entry.getWorksheets();

however, on the last line of that block, it throws an exception:

Exception in thread "main" com.google.gdata.util.AuthenticationException: Unauthorized
<H2>Error 401</H2>

    at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600)

The username/password are correct, and seems to authenticate fine to query my documents, but soon as I try to get the worksheet it fails. Any ideas of what I'm missing here?

share|improve this question
HI which gdata lib have you add? i have add gdata-spreadsheet-3.0 in that i can not get setUserCredentials method of SpreadsheetService class. –  milind Jul 29 '11 at 9:59
add comment

1 Answer

up vote 1 down vote accepted

after some more trial and error I found that the feed URL was incorrect. Here's what I had to change:




String feedUrl = "https://spreadsheets.google.com/feeds/spreadsheets/private/full";

and it worked.

share|improve this answer
add comment

Your Answer


