When I run this, I get an error saying ‘unexpected error in UrlFetchApp.fetch()’. Does anyone know what’s going wrong or have a better way to do this? I’d really appreciate any help!
Hey there! I’ve had similar issues with backing up Google Docs files. From my experience, the method you’re using is a bit outdated. I found a much simpler way using Google Apps Script that’s been working great for me.
Here’s what I do:
I create a script in Google Apps Script that uses the DriveApp service. It loops through my Google Docs, converts each to PDF, and saves them in a specific folder in my Drive. It’s way more straightforward and doesn’t require dealing with complex OAuth setups or XML payloads.
The key is to use DriveApp.getFilesByType() to get all your Docs, then use file.getAs() to convert to PDF. You can even set it up as a time-driven trigger to run automatically.
This approach has been super reliable for me. Plus, it’s easier to troubleshoot if something goes wrong. Give it a shot and let me know if you need any help setting it up!
hey, i’ve had luck with a simpler method using google apps script. instead of messing with all that oauth stuff, try using the DriveApp service. it lets u loop thru ur docs, convert to PDF, and save em in a folder. way easier to set up and troubleshoot. lemme know if u want more details on how to do it!
I’ve faced similar challenges when backing up Google Docs. From my experience, the most reliable method is using Google Apps Script with the DriveApp service. It’s straightforward and doesn’t require complex authentication.
Here’s a simple script I’ve used successfully:
function backupDocs() {
var backupFolder = DriveApp.getFolderById('YOUR_BACKUP_FOLDER_ID');
var docs = DriveApp.getFilesByType(MimeType.GOOGLE_DOCS);
while (docs.hasNext()) {
var doc = docs.next();
var pdfBlob = doc.getAs(MimeType.PDF);
backupFolder.createFile(pdfBlob);
}
}
This script loops through all your Google Docs, converts each to PDF, and saves them in a specified backup folder. You can easily modify it to include other file types or set specific naming conventions.
Remember to replace ‘YOUR_BACKUP_FOLDER_ID’ with the actual ID of your backup folder in Google Drive. You can find this ID in the folder’s URL.
This method has been reliable for me and is much easier to manage than dealing with external APIs. Give it a try and let me know if you need any clarification!