Thursday, January 2, 2014

Google Spreadsheet API - Java - com.google.gdata.util.ParseException: Unrecognized content type:application/binary

I was developing an application using Google Spreadsheet API.  I was trying to load a particular spreadsheet in my application. This was the code:

URL spreadSheetUrl = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
SpreadsheetQuery query = new SpreadsheetQuery(spreadSheetUrl);
query.setTitleQuery("xyz");
query.setTitleExact(true);
SpreadsheetFeed spreadSheetFeed = service.getFeed(query, SpreadsheetFeed.class);

I was getting this error:

com.google.gdata.util.ParseException: Unrecognized content type:application/binary
com.google.gdata.client.Service.parseResponseData(Service.java:2136)
com.google.gdata.client.Service.parseResponseData(Service.java:2098)
com.google.gdata.client.Service.getFeed(Service.java:1136)
com.google.gdata.client.Service.getFeed(Service.java:1077)
com.google.gdata.client.GoogleService.getFeed(GoogleService.java:676)
com.google.gdata.client.Service.getFeed(Service.java:1034)

Apparently, this is because I did not give user credentials to access the spreadsheet. For some reason, Google does not return a valid response if the user is not logged in. It could return - NotAuthorizedException or something like that. But it keeps returning ParseException.

No comments:

Post a Comment