GAS openByUrl()错误:无效参数:url

时间:2014-02-01 13:14:48

标签: url google-apps-script google-docs

为什么这段代码:

var target = createDuplicateDocument(template, docName);
var targetDocId = target.getId();
var link = target.getUrl();
var myVariable = DocumentApp.openByUrl(newDocLink).getText();

产生此错误?

14-02-01 11:02:37:973 BRST] DocumentApp.openByUrl([https://docs.google.com/open?id=1kQWDgh7Qe80pCuvs2VQjPhJGCSk9KXXXs4Nqt2pLH1c]) [0 segundos]
[14-02-01 11:02:38:931 BRST] Falha na execução: Argumento inválido: url (line 238, file "mainScript") [2.796 segundos de tempo de execução total]

我也试过var myVariable = DocumentApp.openByUrl(newDocLink[0]).getText();但它没有用。我知道我可以使用openById,但我想让openByUrl正常工作。谢谢!

1 个答案:

答案 0 :(得分:1)

newDocLink永远不会在上面用作参数的地方定义。