0
私が本当に助けてくれることを願っています。Google Appsスクリプトで返されたコード500
このgoogle appsスクリプトは、GoogleシートをPDFに変換して電子メールで送信し、特定のGoogleドライブフォルダにPDFのコピーを保存する際にうまく機能しています。しかし、今はそれが動作を停止していないと私に以下のエラーを与える。私の最後には何も変わらず、最後に成功した試み/送信は2016年4月でした。昨年、G-appsのアップデートはありましたか?
はここでエラーです:
Request failed for https://docs.google.com/a/filmclosings.com/spreadsheets/d/1Shy55DRkwKdSGayWQYKV6bCPMvm2qfgK3zD_plyi8lE/export?exportFormat=pdf&format=pdf&size=letter&portrait=false&fitw=true&source=labnol&sheetnames=false&printtitle=false&pagenumbers=false&gridlines=false&fzr=false&gid=1082764768 returned code 500. Truncated server response: <!DOCTYPE html><html lang="en" ><head><meta name="description" content="Web word processing, presentations and spreadsheets"><meta name="viewport" ... (use muteHttpExceptions option to examine full response)
、ここだ、私のGoogleは、スクリプトをアプリ:
/* Send Spreadsheet in an email as PDF, automatically */
function emailSpreadsheetAsPDF() {
// Send the PDF of the spreadsheet to this email address
//var email = "[email protected]";
var originalSpreadsheet = SpreadsheetApp.getActive();
var Output = originalSpreadsheet.getSheetByName("Output-BASIC");
var email = Output.getRange("M2").getValue();
// Subject of email message
// The date time string can be formatted in your timezone using Utilities.formatDate method
//var subject = "PDF Reports - " + (new Date()).toString();
var subject = "Film Closings Finance Plan";
// Get the currently active spreadsheet URL (link)
// Or use SpreadsheetApp.openByUrl("<<SPREADSHEET URL>>");
var ss = SpreadsheetApp.openById('1Shy55DRkwKdSGayWQYKV6bCPMvm2qfgK3zD_plyi8lE');
//var ss = SpreadsheetApp.getActiveSpreadsheet();
// Email Body can be HTML too with your logo image - see ctrlq.org/html-mail
//var body = "PDF generated using code at ctrlq.org from sheet " + ss.getName();
var body = "Hello and thank you for your order - attached is the PDF of your Finance Plan from FilmClosings.com";
var url = ss.getUrl();
//var url = "https://docs.google.com/spreadsheets/d/1Shy55DRkwKdSGayWQYKV6bCPMvm2qfgK3zD_plyi8lE/edit";
url = url.replace(/edit$/,'');
/* Specify PDF export parameters
// From: https://code.google.com/p/google-apps-script-issues/issues/detail?id=3579
exportFormat = pdf/csv/xls/xlsx
gridlines = true/false
printtitle = true (1)/false (0)
size = legal/letter/ A4
fzr (repeat frozen rows) = true/false
portrait = true (1)/false (0)
fitw (fit to page width) = true (1)/false (0)
add gid if to export a particular sheet - 0, 1, 2,..
*/
var url_ext = 'export?exportFormat=pdf&format=pdf' // export as pdf
+ '&size=letter' // paper size
+ '&portrait=false' // orientation, false for landscape
+ '&fitw=true&source=labnol' // fit to width, false for actual size
+ '&sheetnames=false&printtitle=false' // hide optional headers and footers
+ '&pagenumbers=false&gridlines=false' // hide page numbers and gridlines
+ '&fzr=false' // do not repeat row headers (frozen rows) on each page
+ '&gid='; // the sheet's Id
var token = ScriptApp.getOAuthToken();
var sheets = ss.getSheets();
//make an empty array to hold your fetched blobs
var blobs = [];
for (var i=0; i<sheets.length; i++) {
// Convert individual worksheets to PDF
var response = UrlFetchApp.fetch(url + url_ext + sheets[i].getSheetId(), {
headers: {
'Authorization': 'Bearer ' + token
}
});
//convert the response to a blob and store in our array
blobs[i] = response.getBlob().setName(sheets[i].getName() + '.pdf');
}
//create new blob that is a zip file containing our blob array
var zipBlob = Utilities.zip(blobs).setName(ss.getName() + '.zip');
//optional: save the file to the root folder of Google Drive -- Jeff activated this and changed to go a specific Drive folder
DriveApp.getFolderById('0B59I-GV_lvsJaHdOUEZVMktzMHc').createFile(blobs[0]).setName(email+ ' Finplan');
// Define the scope
Logger.log("Storage Space used: " + DriveApp.getStorageUsed());
// If allowed to send emails, send the email with the PDF attachment
if (MailApp.getRemainingDailyQuota() > 0)
GmailApp.sendEmail(email, subject, body, {cc:"[email protected]", attachments:blobs[0] });
//GmailApp.sendEmail(email, subject, body, {attachments:[zipBlob]});
}
は、私は本当にあなたの時間と洞察力に感謝します。
ベスト、
JD
OAuthを使用しています。おそらくあなたの 'token'には問題があります。私は何らかの変化があったと思うが、わからない。 OAuth認証にライブラリを使用していますか? –
私がOAuthについて知っている唯一のニュースは、次の記事[Link to Apps Script Community](https://plus.google.com/+EricKoleda/posts/K7P7pHefXir)にあります。問題が承認の問題でない場合は、検索文字列のパラメータを持つものかもしれません。それぞれの検索文字列パラメータを最後から1つずつ削除して、それぞれを試してみたことがありますか?あなたのお返事には@SandyGoodに感謝します。 –
最初にスクリプトを使用しようとしたとき、電子メールを承認するよう依頼しました(これは私が最初に使ったのと同じです)。私はちょうどその許可が失効した11ヶ月だったと仮定した。承認中にエラーはありませんでした。スクリプトを実行しているときだけです。 – maguffinator