Skip to content

Instantly share code, notes, and snippets.

@phukon
Created March 11, 2024 12:06
Show Gist options
  • Save phukon/baa4a2c8e416b59f5079c35b7efbc646 to your computer and use it in GitHub Desktop.
Save phukon/baa4a2c8e416b59f5079c35b7efbc646 to your computer and use it in GitHub Desktop.
Google doc as html content dynamically
function doGet(e){
let id = '1fK1zbSNw7jZuEB14iS8n6t9p7PV4tFQW8fJpnJMpFWA';
if('id' in e.parameter){
id = e.parameter['id']
}
let html = '<h1>Laurence Svekis</h1>';
const url = 'https://docs.google.com/feeds/download/documents/export/Export?id='+id+'&exportFormat=html';
const param = {
method :"get",
headers : {
"Authorization":"Bearer "+ScriptApp.getOAuthToken()
},
muteHttpExceptions:true
};
html = UrlFetchApp.fetch(url,param).getContentText();
return HtmlService.createHtmlOutput(html);
}
function testHTML(){
const id = '1Ypgk3FCRN-s70jvWwKKEUll7zIfTY';
const url = 'https://docs.google.com/feeds/download/documents/export/Export?id='+id+'&exportFormat=html';
const param = {
method :"get",
headers : {
"Authorization":"Bearer "+ScriptApp.getOAuthToken()
},
muteHttpExceptions:true
};
html = UrlFetchApp.fetch(url,param).getContentText();
Logger.log(html);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment