[英]Connect apiary.io REST API v1+ in Google Data Studio
我需要將apiary.io REST API v1 +連接到Google Data Studio
。
正如我檢查的那樣,我需要在Google Apps Script中開發一個使用JavaScript
的連接器,正如我在這些教程中檢查的那樣, 連接並可視化Data Studio和External API中的 所有數據 。
在逐步的軟件制造商中, piperun REST API v1 + 。 有幾個代碼片段,但是我無法使它們在GDS
工作。
不幸的是,我沒有太多的JavaScript
經驗,我的主要技能是T-SQL
,但是我可以在Microsoft PowerBI
成功建立連接。 但我可以通過插入使微軟PowerBI成功連接URLs
和TOKENS
訪問的,具有返回代碼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。服務器被截斷:{“成功”:false,“消息”:“未經授權”}(使用muttHttpExceptions選項檢查完整答案) (第8行,文件“代碼”)
因此,我想幫助您確定是否存在另一種簡便方法,或者需要學習什么才能建立與apiary.io REST API v1+
的連接。
在朋友開發人員的幫助下,我們提供以下解決方案:
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());
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.