google-apps-script - 从 Gmail.Users.history.list API 检索历史列表时出错
问题描述
我正在尝试检索历史列表并使用 Gmail API 找出新添加的消息。我正在使用 Google 脚本来执行此操作。
这是我定义的监视请求。我将响应的 historyId 分配给histId变量。
var watchResource = Gmail.newWatchRequest();
watchResource.labelIds = ["INBOX"];
watchResource.labelFilterAction = "include";
watchResource.topicName = "projects/project-id-xxxxxxxxxxxx/topics/gmailTrigger";
var response = Gmail.Users.watch(watchResource, userId);
var histId = response.historyId;
我正在使用这种方法来获取历史列表。
var his = Gmail.Users.History.list(userId,{'startHistoryId': histId});
Logger.log(his);
当我使用histId变量作为“startHistoryId”的参数时,它应该向我发送收件箱的历史列表。但这并没有给我预期的输出。
预期输出 - “{historyId=7092010, history=[{messagesAdded=[{message={threadId=16xxxxxxxxxf, labelIds=[UNREAD, CATEGORY_FORUMS, Label_24593xxxxxxxxxx7]}”
我得到的输出 - “{historyId=7092010}”
但是,当我将从响应 (response.historyId) 收到的 historyId 硬编码到上述代码时,它给了我预期的输出。
var his = Gmail.Users.History.list(userId,{startHistoryId: 7092010});
Logger.log(his);
有人可以帮我弄这个吗?我需要使用该变量而不对其进行硬编码。
解决方案
推荐阅读
- python - 在android上运行selenium python脚本
- java - 包含初始化的for循环在语法和语义上是否正确?
- apache-spark - 读取没有分区列名的分区列
- dart - 如何检查元素的 DartType 是自定义类型?
- javascript - Keydown Javascript 函数在移动平台上不返回 false /exit(代码适用于桌面)
- php - 你好,我用php curl做了一个研究,响应没有我想要的响应。问题出在哪里?
- django - IntegrityError(错误)而不是 ValidationError(正确)
- python - 将字符串拆分为字母组,忽略空格
- python - 我想使用 discord.py 发出命令,当有人对消息做出反应时触发
- go - 我可以使用 go 命令行工具设置 GOPATH 吗?