javascript - 使用 Zenloop 的 API 和 Apps 脚本将数据从 Zenloop 拉入 Google 表格
问题描述
我正在尝试使用 Apps Script 将 Zenloop(调查工具)中的调查数据自动提取到 Google 表格中。执行该函数时,会出现以下错误:
错误:
异常:返回代码 401 的请求失败
https://api.zenloop.com
。截断的服务器响应:{"error":{"code":"UNAUTHORIZED","status":401,"title":"Invalid or expired token."}}(使用 muteHttpExceptions 选项检查完整响应)
脚本:
function myFunction() {
const options = {
method: 'GET',
headers: {
Authorization: 'XXXXXXXXXXX',
'Content-Type': 'application/json'
}
};
UrlFetchApp.fetch('https://api.zenloop.com/v1/survey_groups/XXXXXXXXXXX/answers?date_shortcut=all_time&order_type=desc&page=1', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
}
我已经删除了 API 密钥和调查 ID。我是 Apps Script/Javascript 的新手,所以这里的任何人都会非常感激。API 密钥或调查 ID 没有问题,我已经检查了三次。
解决方案
推荐阅读
- amazon-web-services - 无法访问已部署的 beanstalk 多容器应用程序
- jekyll - Jekyll 无法处理 scss
- xslt - XSL 键匹配一个或多个子节点
- sql - 如何使一个值取代所有其他值,以便无论组合如何都始终选择特定值?
- android - 使用按钮 setOnTouchListener 略有延迟
- reactjs - Mobx:是否有可能在可观察对象的 get 属性上设置挂钩?
- c# - RabbitMQ 发布/消费消息很慢
- javascript - 如何使用 JavaScript 从实时输出流中获取数据
- java - Java/Groovy 如何正确比较两个字符串值?.equals() 不工作
- mysql - 如何选择给定的表?