如何使用Google API服务库(Node.js)运行Google App脚本 [英] How to run a Google App Script using Google API Service Library (Node.js)
问题描述
按照Google Apps脚本> Rest API Node.js快速入门示例,我能够完成身份验证过程(跟随链接,获取令牌,存储令牌)
By following the Google Apps Script > Rest API Node.js quickstart example I am able to complete the authentication process (follow the link, get a token, store the token)
但是脚本执行失败并显示错误消息
but the script execution fails with the error message
The API returned an error: Error: Project title may not be empty.
project.create()的文档指示请求正文仅需要包含{title:string},即快速入门的内容.
The documentation for project.create() indicates the request body only need contain {title:string} which what the quickstart has.
仔细检查Google Apps Script API是否已启用=是,但是api启用页面显示了一些不应包含的html代码,并启用了该代码以供使用网址已损坏.
Double check Google Apps Script API is enabled = yes,but the api enable page shows some html code it shouldn't, and the enable it for use url in the Overview sections of that page is broken.
我很确定启用API,因为我在console.cloud中看到了流量
I pretty sure the API is enabled as I see traffic in console.cloud
方法看起来像这样.
script.projects.create({
auth,
resource: {
title: 'My Script'
}
});
我还尝试了auth:auth,因为这是我在其他地方看到的工作(错误消息msg)
I also tried auth: auth as that is what I have seen working elsewhere (same error msg)
错误堆栈如下所示.
The error stack looks like this.
换句话说,我完全遵循了快速入门,并检查了功能文档无济于事,能帮上什么忙吗?
In other words, I followed the quick start exactly and checked function documentation to no avail, can some one help?
推荐答案
我认为您的请求正文有效.那么您可以确认以下几点吗?
I think that your request body works. So can you confirm the following points?
- 您使用的是哪个版本?在我的环境中,无法使用v25.0.0-v30.0.0的googleapis.我确认使用v24.0.0的googleapis可以正常工作.
- 使用v24.0.0时,如果脚本使用
var {google} = require('googleapis');
,请修改为var google = require('googleapis');
.
- 使用v24.0.0时,如果脚本使用
- What version are you using? In my environment, googleapis with v25.0.0 - v30.0.0 cannot be worked. I confirmed that googleapis with v24.0.0 works fine.
- When you use v24.0.0, if your script use
var {google} = require('googleapis');
, please modify tovar google = require('googleapis');
.
- When you use v24.0.0, if your script use
注意:
- 不幸的是,在v25.0.0版本之后,报告了一些API和选项的错误.我相信将来会删除这些错误.因此,如果对于API和您使用的选项,会发生一些错误,请修改googleapis的版本,然后重试.
- 如何更新我的Google工作表在v4中?
- 尝试通过API(v3)在Google云端硬盘上创建文件夹时权限不足
- Youtube Data API V3-使用google.youtube.videos.list() 提取视频时出错
- Google驱动器API-无法读取属性'OAuth2 'of undefined
- How do I update my google sheet in v4?
- Create a gmail filter with Gmail API nodejs, Error: Filter doesn't have any criteria
- Insufficient Permission when trying to create a folder on Google Drive via API(v3)
- Youtube Data API V3 - Error fetching video with google.youtube.videos.list()
- Google drive API - Cannot read property 'OAuth2' of undefined
如果这些要点对您的情况没有帮助,对不起.
If these points were not useful for your situation, I'm sorry.
这篇关于如何使用Google API服务库(Node.js)运行Google App脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!