I sincerely someone can help me with this. My end goal is to be able to get the plain text representation of a google slides deck just like what you get when you are in the editor and go to File->Download-Plain text. I need to get this txt inside my google appscript code as a string.
From what I have gathered so far this is not possible using the Slides API. Objects like Presentation, Slide etc don't appear to have export asString() methods. So I looked at the http requests executed when I use the UI in editor mode.
Turns out that if you replace the /edit in your URL with /export/txt of any google slide deck you get redirected to an export to txt.
So I coded this inside my appscript project with URL fetch to get to it:
var l_sDocID = _deck.getId(); // A Drive File
var l_httpOptions = {"contentType" : "text/plain",
"method" : "get",
"followRedirects" : true,
"muteHttpExceptions" : true,
"Authorization" : "Bearer " + ScriptApp.getOAuthToken()};
var l_sExportURL = "https://docs.google.com/presentation/d/" + l_sDocID + "/export/txt";
logger.log(UrlFetchApp.fetch(l_sExportURL, l_httpOptions).getContentText());
For the life of me I cannot figure out what I am doing wrong but I get Error 400 each time. When I hit the same URL in my browser which is already authenticated to the google domain the redirect happens and I get the content I am after.
If there are other ways to do this instead of http round trip inside google I am happy to look at that but I haven't found one yet.
My project is based on the REST wrappers so uses DriveApp etc. I don't know if one can mix this with the V2 REST api without wrappers but if so I am happy to consider that also if it will address this issue.
Please help anyone?