orphetov
orphetov

Reputation: 11

Why does my Google App script expect a function to be in a file rather than in the script?

I keep getting an error in Google App script when running a function with this variable:

Execution failed: TypeError: Cannot find function getContentAsString in object file_here

var doc = DriveApp.getFolderById('*FOLDER_ID*');
doc.createFile(file).getContentAsString();

Any ideas why? What's the proper way to do this?

Upvotes: 1

Views: 83

Answers (1)

ScampMichael
ScampMichael

Reputation: 3728

doc.createFile(file).getAs('text/plain').getDataAsString();

or

doc.createFile(file).getBlob().getDataAsString();

https://developers.google.com/apps-script/reference/base/blob

Upvotes: 1

Related Questions