我是Tableau Web数据连接器和编程的新手,但我正在尝试创建yelp数据连接器。
当我按获取数据时,将弹出WDC验证错误。
这是控制台中的错误消息:
“数据类型不能为空”
这是我拥有的Yelp.js文件,不太确定错误消息指的是什么?
定义数据源将要拥有的架构 <-似乎是此架构的问题所在?但这不是空白。
myConnector.getSchema = function(schemaCallback) {
//Each item represents a column in tableau
var cols = [{
id: "term",
alias: "search term",
dataType: tableau.dataTypeEnum.string
}, {
id: "location",
alias: "location",
dataType: tableau.dataTypeEnum.string
}, {
id: "latitude",
alias: "lat",
dataType: tableau.dataTypeEnum.decimal
}, {
id: "longitude",
alias: "lon",
dataType: tableau.dataTypeEnum.decimal
}, {
id: "radius",
alias: "radius",
dataType: tableau.dataTypeEnum.tnteger
}, {
id: "open_now",
alias: "open now",
dataType: tableau.dataTypeEnum.boolean
}, {
id: "open_at",
alias: "open at",
dataType: tableau.dataTypeEnum.integer
}];
var tableInfo = {
id: "yelpsearch",
alias: "Yelp Business Search",
columns: cols
};
以下代码段用于下载数据
myConnector.getData = function(table, doneCallback) {
var term = "",
location = "",
latitude = 0,
longitude = 0,
radius = 0,
open_now = true,
open_at = 0;
从邮递员复制
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.yelp.com/v3/businesses/search",
"method": "GET",
"headers": {
"Authorization": "Bearer API KEY HERE",
"cache-control": "no-cache",
"Postman-Token": "POSTMAN TOKEN HERE"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
遍历JSON对象
$.getJSON("https://api.yelp.com/v3/businesses/search", function(resp) {
tableData = [];
for (var i = 0, len = resp.length; i < len; i++) {
tableData.push({
"term" : resp[i].term,
"location" : resp[i].location,
"latitude" : resp[i].latitude,
"longitude": resp[i].longitude,
"radius" : resp[i].radius,
"open_now" : resp[i].open_now,
"open_at" : resp[i].open_at,
});
}
table.appendRows(tableData);
doneCallback();
});
};
如果有人能对此有所了解,将不胜感激。谢谢!
这是Yelp的API文档
https://www.yelp.com/developers/documentation/v3/business_search