如何使用Google表格导入JSON

问题描述 投票:0回答:1

= ImportJSON(https://github.com/bradjasper/ImportJSON)推送了我正在尝试的URL错误,我认为是由于未在查询中正确输入过滤器:

https://api.keen.io/3.0/projects/PROJECTID/queries/extraction?api_key=APIKEY&analysis_type=extraction&event_collection=items&filters=[{%22operator%22:%20%22eq%22,%20%22property_name%22:%20%22USERNAME%22,%20%22property_value%22:%20%221550%22}]&timeframe=today&timezone=America/Chicago

原因:

[异常:无效的参数:https://api.keen.io/3.0/projects/PROJECTID/queries/extraction?api_key=APIKEY&analysis_type=extraction&event_collection=items&filters=[{%22operator%22:%20%22fh%22,%20%22property_name%22:%20%22USERNAME%22,%20%22property_value%22:%20%221550%22}]&timeframe=today&timezone=America/Chicago(第217行)。

第217行是此函数的第二行:

function ImportJSONAdvanced(url, fetchOptions, query, parseOptions, includeFunc, transformFunc) {
  var jsondata = UrlFetchApp.fetch(url, fetchOptions);
  var object   = JSON.parse(jsondata.getContentText());

  return parseJSONObject_(object, query, parseOptions, includeFunc, transformFunc);
}

如果我删除&filters=[{%22operator%22:%20%22fh%22,%20%22property_name%22:%20%22USERNAME%22,%20%22property_value%22:%20%221550%22}]但推入太多数据并且查询时间很长,则可以使用,否则我将只使用它并过滤所需的结果。

我能够通过chrome URL毫无问题地访问它,因此我必须正确设置过滤器的格式才能处理Google表格/应用程序。

json google-apps-script google-sheets keen-io importjson
1个回答
0
投票

[我在https://keen.io担任解决方案工程师。

看来您的时间范围和时区格式不正确。通常,我们的端点接受这样编写的那些属性。还要注意,我们的过滤器查询参数是在时间范围和时区之后编写的。此查询是当前日期(今天)的工作查询,时区0应该对应于美国/中部(美国/芝加哥)https://api.keen.io/3.0/projects/PROJECT_ID/queries/count?api_key=API_KEY&analysis_type=%22count%22&event_collection=%22commit_comment%22&timeframe=%22this_1_days%22&timezone=0&filters=%5B%7B%22property_name%22%3A%22hook.name%22%2C%22operator%22%3A%22eq%22%2C%22property_type%22%3A%22String%22%2C%22property_value%22%3A%22web%22%7D%5D

请参考我们的API文档,尤其要注意时间戳,日期时间解析器和查询参数过滤器部分https://keen.io/docs/api

© www.soinside.com 2019 - 2024. All rights reserved.