Hi,
I tried to download a spreadsheet. This is what I did:
DocsService service = new DocsService("GDoc Service test by TW");
service.setUserCredentials("usr", "pwd");
URL documentListFeedUrl = new URL("
https://docs.google.com/feeds/default/private/full/");
DocumentListFeed feed = service.getFeed(documentListFeedUrl, DocumentListFeed.class);
then I created:
String exportUrl = "
https://spreadsheets.google.com/feeds/download/spreadsheets" + "/Export?key=" + docId + "&exportFormat=" + "xls";
After that I did:
MediaContent mc = new MediaContent();
mc.setUri(exportUrl);
My program returns the following:
com.google.gdata.util.AuthenticationException: Unauthorized
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.google.gdata.client.media.MediaService.getMediaResource(MediaService.java:234)
at com.google.gdata.client.media.MediaService.getMedia(MediaService.java:276)
at com.google.gdata.client.media.MediaService.getMedia(MediaService.java:302)
at dashboard.GetGoogleDoc.getEvaluationSpreadsheet(GetGoogleDoc.java:88)
at dashboard.GetGoogleDoc.main(GetGoogleDoc.java:26)
I did some search and found somebody mentioned google Doc API service and spreadsheet API service are different. So I change the service binding to be
SpreadsheetService service = new SpreadsheetService("writely");
I am lost now. Which feedURL should I use?
1)
https://docs.google.com/feeds/default/private/full/ or
2)
https://spreadsheets.google.com/feeds/default/private/full/ or
3)
https://docs.google.com/feeds/default/private/full/-/spreadsheet?max-results=1 ????
another problem is SpreadsheetService doesn't have a method called getMedia(MediaContent mc). how should I download the file?
anybody shed some light on me?
Thanks!