简体   繁体   English

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

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

I need to connect apiary.io REST API v1+ to Google Data Studio . 我需要将apiary.io REST API v1 +连接到Google Data Studio

As I checked, I need to develop a connector with JavaScript in Google Apps Script , as I checked in these tutorials Connect and visualize all your data in Data Studio and External APIs . 正如我检查的那样,我需要在Google Apps Script中开发一个使用JavaScript的连接器,正如我在这些教程中检查的那样, 连接并可视化Data StudioExternal API中的 所有数据

In this step by step software manufacturer, piperun REST API v1+ . 在逐步的软件制造商中, piperun REST API v1 + There are several code snippets, but I can not make them work in GDS . 有几个代码片段,但是我无法使它们在GDS工作。

Unfortunately I do not have much experience with JavaScript , my main skill is with T-SQL , but I could make the successful connections in Microsoft PowerBI . 不幸的是,我没有太多的JavaScript经验,我的主要技能是T-SQL ,但是我可以在Microsoft PowerBI成功建立连接。 But I was able to make the connections successfully in Microsoft PowerBI by inserting the URLs and the TOKENS of access, having the return code 200 . 但我可以通过插入使微软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();  
}

And even if you enter a valid TOKEN , the error occurs: 即使输入有效的TOKEN ,也会发生错误:

Failed to request https://api.pipe.run/v1/activities returned code 401. Truncated server response: {"success": false, "message": "Unauthorized"} (use the muteHttpExceptions option to examine the complete answer) (line 8, file "Code") 无法请求https://api.pipe.run/v1/activities返回代码401。服务器被截断:{“成功”:false,“消息”:“未经授权”}(使用muttHttpExceptions选项检查完整答案) (第8行,文件“代码”)

So I would like help finding out if there is another easy way or what I need to learn to be able to establish a connection to apiary.io REST API v1+ . 因此,我想帮助您确定是否存在另一种简便方法,或者需要学习什么才能建立与apiary.io REST API v1+的连接。

With the help of a friend developer, we solve with the following solution: 在朋友开发人员的帮助下,我们提供以下解决方案:

   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