I was trying to do programming using Java to connect to Google Spreadsheet to do data retrieval or modifying data in the cells.
My Google spreadsheet link is https://doc
I was also getting the com.google.gdata.util.ParseException: Unrecognized content type:application/binary
error, but I seem to have stumbled on a workaround for this strange bug. The code in Alex R's answer can be used as a starting point.
First I tried changing the visibility to "public"
, just to see what would happen. Since the document is not published, I got the expected error response, containing:
We're sorry. This document is not published.
So I changed the visibility back to "private"
, and tried again just for fun...
Lo, and behold; it worked!
It works with either the Drive or Spreadsheets Feed scope (both can be included if you prefer):
I'm not sure if its a factor, but I'm not using OAuth 2.0, but rather a Credential
created from a PrivateKey
(PKCS12 file), as in Brian Chapman's answer.
Conclusion
So, although it's kludgy, I've modified my application to always make a "public"
request (wrapped in a try
block to absorb the resulting Exception
) just before making the "private"
request. It's the only way I've been able to deterministically get the correct result.