首页 > 解决方案 > Yelp Tableau Web 数据连接器

问题描述

我是 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

标签: apitableau-api

解决方案


推荐阅读