簡體   English   中英

在Google Data Studio中連接apiary.io REST API v1 +

[英]Connect apiary.io REST API v1+ in Google Data Studio

我需要將apiary.io REST API v1 +連接到Google Data Studio

正如我檢查的那樣,我需要在Google Apps Script中開發一個使用JavaScript的連接器,正如我在這些教程中檢查的那樣, 連接並可視化Data StudioExternal API中的 所有數據

在逐步的軟件制造商中, piperun REST API v1 + 有幾個代碼片段,但是我無法使它們在GDS工作。

不幸的是,我沒有太多的JavaScript經驗,我的主要技能是T-SQL ,但是我可以在Microsoft PowerBI成功建立連接。 但我可以通過插入使微軟PowerBI成功連接URLsTOKENS訪問的,具有返回代碼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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM