0

I am working on a application where I need to convert a newly uploaded Google Spreadsheet file in the google docs to public. I am using Drive API to upload the file to Google Drive and using Mime Types I am converting the file to the Google Spreadsheets format.

There is an option in Google Spreadsheet Interface to make the spreadsheet public, but I need to do it programmatically using java as there are multiple spreadsheets that get uploaded to the Google Drive.

Please Suggest.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
Karan Tongay
  • 197
  • 1
  • 17
  • You seems to be looking for Permission.domain property - https://developers.google.com/drive/v3/reference/permissions/create – chanaka777 Jan 09 '17 at 11:01
  • Thanks, I have used permissions create, but I couldn't find the option to publish spreadsheet publicly, even if I set role to writer or reader and type to anyone still I cannot access spreadsheet from my Java code unless I publish it to Web from user interface of Google Spreadsheet – Karan Tongay Jan 09 '17 at 13:09

1 Answers1

1

AFAIK, you need to publish your spreadsheets to the web so you can access its contents.

As stated in the Sheets API URLs, visibilities, and projections , the public visibility is supported for spreadsheets that have been "Published to the Web".

Please note of the given warnings:

  • API requests using the public visibility for feeds on spreadsheets that are not "Published to the Web" yield an HTTP 400 Bad Request response The spreadsheet at this URL could not be found. Make sure that you have the right URL and that the owner of the spreadsheet hasn't deleted it.

  • The public visibility does not work for spreadsheets that are made "Public on the web" from the "Visibility options" portion of the sharing dialog of a Google Sheets file. "Published to the web" and "Public on the web" are different ways to share a spreadsheet. We are aware that this is confusing, and will address it in a future version of the API. For now, we hope that this detailed warning prevents confusion.

If your looking for ways to programmatically publish your Google Docs, you may set published property to true using Revisions.update.

This related SO thread might also help but it's done in JS.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22