Code Guy
Code Guy

Reputation: 3198

Publish the slides file using apps script slide (GAS) service

I need to publish the Slide file to website and get the published URL, But I am not getting the published URL as a return response.

The Drive service is turned on already.

I tried with

function doGet(e) {    
  var ppt = SlidesApp.openByUrl('https://docs.google.com/presentation/d/1fIQpQJ8QaIqt3fibTGmlAndZuvDG3ry8maAm_0CgSLE/edit#slide=id.p');
  var fileId = ppt.getId();
  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.publishAuto = true;
  resource.publishedOutsideDomain = true;
  resource.published = true;    
  return ContentService.createTextOutput(JSON.stringify(Drive.Revisions.update(resource, fileId, revisionId).publishedLink));
}

Upvotes: 1

Views: 203

Answers (1)

Iamblichus
Iamblichus

Reputation: 19319

This might be a bug:

The publishedLink from a published Revision (for Sheets, Docs and Slides, at least) is not populated. This seems to be the case for both V2 and V3.

This behaviour was reported some time ago in Issue Tracker:

I'd suggest you to star the issue in order to give it more visibility.

In this case, I think a workaround could be to work with one of the Revision exportLinks instead.

Upvotes: 1

Related Questions