【发布时间】:2022-01-12 15:09:41
【问题描述】:
我对编码完全陌生。我正在尝试在 Klipfolio 中构建仪表板。我正在使用 CATSone API 将数据从 CATSone 提取到 Klipfolio。但是,我一次只能获取 100 行,这意味着我必须拉数据 2600 次。
我现在正在尝试构建一个脚本以通过 Google 脚本编辑器从 API 获取数据。但是,由于我没有这方面的经验,我只是在尝试一些东西。我看了一些视频,也是 Ben Collins 的。基础很简单,我明白他在做什么。
但是,我在放置 API 密钥时遇到了问题。
var API_KEY = 'key'
function callCATSone(){
//Call the CATSone API for all candidate list
var response = UrlFetchApp.fetch("https://api.catsone.nl/v3/candidates");
Logger.log(response.getContentText());
// URL and params for the API
var url = 'https://api.catsone.nl/v3/candidates';
var params = {
'method': 'GET',
'muteHttpExceptions': true,
'headers': {
'Authorization': 'key ' + apikey
}
};
// call the API
var response = UrlFetchApp.fetch(url, params);
var data = response.getContentText();
var json = JSON.parse(data);
}
最后,我想将所有候选人列表数据转移到我的工作表中。因此,我使用授权密钥调用 API。之后,我将处理数据,但那是以后的事了。我现在遇到的第一个问题,就是这个失败代码:
'Verzoek voor https://api.catsone.nl/v3/candidates 是错误的。 Foutcode: 401. Ingekorte serverreactie: {"message":"Invalid credentials."} (Gebruik de optie muteHttpExceptions om de volledige reactie te onderzoeken.) (regel 6, bestand 'Code')'。
我希望将来自 CATSone 的所有数据的列表添加到我的工作表中。
有谁知道我如何做到这一点?
【问题讨论】:
标签: api google-apps-script urlfetch