【发布时间】:2019-06-28 01:09:17
【问题描述】:
我需要将apiary.io REST API v1+ 连接到Google Data Studio。
正如我检查的那样,我需要在Google Apps Script 中开发一个带有JavaScript 的连接器,正如我在这些教程Connect and visualize all your data in Data Studio 和External APIs 中检查的那样。
在这一步一步的软件制造商,piperun REST API v1+。有几个代码 sn-ps,但我不能让它们在GDS 中工作。
很遗憾我对JavaScript没有太多经验,我的主要技能是T-SQL,但我可以在Microsoft PowerBI上建立成功的联系。但是我能够通过插入URLs 和TOKENSof 访问权限在Microsoft PowerBI 中成功建立连接,返回码为200。
function teste() {
var url = 'https://api.pipe.run/v1/activities';
var request = UrlFetchApp;
request.fetch(url);
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
var request = new XMLHttpRequest();
request.open('GET', 'https://api.pipe.run/v1/activities/activity_id');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Token', 'Q3VydGl1IGVzc2Ugam9iPyEgdHJhYmFsaGVjb25vc2NvQHBpcGUucnVu'); // Here I add TOKEN supplied internally by the application
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
}
而且即使你输入了一个有效的TOKEN,也会出现错误:
请求 https://api.pipe.run/v1/activities 失败,返回代码 401。截断的服务器响应:{"success": false, "message": "Unauthorized"}(使用 muteHttpExceptions 选项检查完整答案)(第 8 行,文件“代码")
所以我想知道是否有其他简单的方法或者我需要学习什么才能建立与apiary.io REST API v1+ 的连接。
【问题讨论】:
-
查看
urlfetchapp官方文档和FAQhere
标签: javascript google-apps-script google-data-studio urlfetch apiary.io