我需要连接apiary.io REST v1+和Google Data Studio。
正如我所检查的,我需要用JavaScript在Google脚本中开发一个连接器,就像我在这些教程在data中连接和可视化所有数据和外部API中所做的那样。
在这一步中,软件制造商piperun REST v1+。有几个代码片段,但我不能让它们在GDS中工作。
不幸的是,我对JavaScript没有太多的经验,我的主要技能是使用T-SQL,但是我可以在Microsoft PowerBI中成功地建立连接。但是,通过插入URLs和access的TOKENS(返回代码200 ),我在Microsoft中成功地建立了连接。
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失败。截断的服务器响应:{“成功”:false,"message":“未经授权”}(使用muteHttpExceptions选项检查完整的答案)(第8行,文件“代码”)
因此,我想要帮助找出是否有另一种简单的方法,或者我需要学习什么才能建立到apiary.io REST API v1+的连接。
发布于 2019-06-28 20:24:00
在朋友开发人员的帮助下,我们使用以下解决方案进行解决:
function myFunction() {
var token = 'Q3VydGl1IGVzc2Ugam9iPyEgdHJhYmFsaGVjb25vc2NvQHBpcGUucnVu'
var url = 'https://api.pipe.run/v1/deals'
var params = { method:"GET",
headers:{Token: token,
contentType:'application/json',}
};
var response = UrlFetchApp.fetch(url, params);
var json = response.getContentText();
var data = JSON.parse(json);
Logger.log(response.getContentText());
}https://stackoverflow.com/questions/56799898
复制相似问题