1

I activated the Advanced Drive Service (Drive API, V2), and I tried to publish to the web a file

I tried the following, but obviously, I miss something (the resource).

function test(){ var fileId = '1c5fRpKAk2YdUVzCa1LOCqDgTLZmYjsfSvTzR9BSGPYo'; var revisions = Drive.Revisions.list(fileId); var items = revisions.items; var revisionId = items[items.length-1].id; var resource; Drive.Revisions.update( resource , fileId, revisionId).published = true; } 
4
  • Looking at the documentation "This is only populated and can only be modified for Google Docs." It sounds like this might not apply to spreadsheets. developers.google.com/drive/v2/reference/revisions/update Commented Nov 8, 2016 at 1:12
  • The only thing that I can find that gets a "Resource" is var resource = Drive.Revisions.get(fileId, revisionId); Commented Nov 8, 2016 at 1:56
  • Thanks Sandy, I try your piece of code, now there is no error message, but the file is not published. Commented Nov 8, 2016 at 8:01
  • function test(){ var fileId = '1c5fRpKAk2YdUVzCa1LOCqDgTLZmYjsfSvTzR9BSGPYo'; var revisions = Drive.Revisions.list(fileId); var items = revisions.items; var revisionId = items[items.length-1].id; var resource = Drive.Revisions.get(fileId, revisionId); Drive.Revisions.update( resource , fileId, revisionId).published = true; Drive.Revisions.update( resource , fileId, revisionId).publishAuto = true; } Commented Nov 8, 2016 at 8:02

1 Answer 1

5

several months later, we got the solution !!

//this function publish to the web the document given by ID (google sheets or docs) function publishToWeb(){ var fileId = 'WqcTq4c3iumeEUSgPMCcM8yKUqycQsrn_w3XeE'; var revisions = Drive.Revisions.list(fileId); var items = revisions.items; var revisionId =items[items.length-1].id; var resource = Drive.Revisions.get(fileId, revisionId); resource.published = true; resource.publishAuto = true; resource.publishedOutsideDomain = true; Drive.Revisions.update(resource, fileId, revisionId); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.