如何将数据发布到mapquest表

时间:2016-03-13 02:50:09

标签: mapquest

我正在尝试将数据发布到mapquest表中,并且我已根据API

完成了所有操作

这是我的json:

{
    "tableName": "mqap.jZ3uoAVablablabla_reported_points",
    "append": true,
    "returnResults": true, 
    "rows": [
        [
            {
                "mqap_geography": "POINT (-123.3141509 48.4647675)",
                "date": "2016-03-13T02:19:09.674Z",
                "email": "anna@gmail.com",
                "latitude": "48.47542496514236",
                "longitude": "-123.37663650512695",
                "message": "ss",
                "user": "a"
            }
        ]
    ]

}

以下是表格的截图

enter image description here

这是我在Postman中得到的回应

{
  "failures": [
    {
      "reason": "Either no latitude/longitude was provided, or the other information was insufficient for geocoding at or near line #0 of input.",
      "row": ""
    }
  ],
  "append": true,
  "returnResults": true,
  "totalRows": 1,
  "tableName": "mqap.jblablabla_reported_points",
  "tableSize": {
    "raw": 8192,
    "readable": "8 KB"
  },
  "data": {
    "rows": []
  },
  "failureCount": 1,
  "rowCount": 0,
  "info": {
    "statusCode": 0,
    "copyright": {
      "text": "© 2015 MapQuest, Inc.",
      "imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
      "imageAltText": "© 2015 MapQuest, Inc."
    },
    "messages": []
  }
}

我做错了什么?

2 个答案:

答案 0 :(得分:1)

创建表时,默认情况下,地理列应位于表中:mqap_geography。此列将根据其他列中的信息进行填充,具体取决于其数据类型:地理位置,[纬度,经度],[街道,城市,州物业,邮政编码,县,国家]和完整地址。上表中的纬度,经度列是String类型,因此它们不会填充Geography列。

答案 1 :(得分:0)

我遗失的两件事:

  1. 数据库需要拥有地理对象。所以我添加了一个我最终没有使用的latlong Geography对象。
  2. JSON的格式应该如下:

    {
    "tableName": "mqap.jZ3uoAVablablabla_reported_points",
    "append": true,
    "returnResults": true, 
    "rows": [
           [
           {"name":"user","value":user},
           {"name":"email","value":email},
           {"name":"date","value":date},
           {"name":"message","value":message},
           {"name":"latitude","value":latitude},
           {"name":"longitude","value"longitude},
           {"name":"latlong","value":"POINT(" + parseFloat(longitude) + " " + parseFloat(latitude) +")"}
           ]
        ]
    }