谷歌地图引擎批量插入功能错误



尝试将特性大容量插入到表中。这是我的json

{"features":[{"type":"Feature","geometry":{"type":"Point","coordinates":["-80.358681","27.643045"]},"properties":{"gx_id":"84","address":"9037 Somerset Bay Lane, Vero Beach Port St. Lucie FL 32963","name":"x","phone":"x","email":"x","vehicle":"Cadillac ATS"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-81.819611","26.380350"]},"properties":{"gx_id":"85","address":"3951 Lakemont Drive, Bonita Springs Fort Meyers FL 34134","name":"x","phone":"x","email":"x","vehicle":"Toyota  Highlander"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-82.677773","27.427950"]},"properties":{"gx_id":"86","address":"6809 Gulf Of Mexico Dr Longboat Key Sarasota FL 34228","name":"x","phone":"x","email":"x","vehicle":"Cadillac  SRX"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-82.677773","27.427950"]},"properties":{"gx_id":"87","address":"6809 Gulf Of Mexico Dr Longboat Key, Sarasota FL 34228","name":"x","phone":"x","email":"x","vehicle":"Cadillac SRX"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-81.818977","26.590782"]},"properties":{"gx_id":"88","address":"10381 McArthur Palm Lane, Fort Myers Fort Meyers FL 33950","name":"x","phone":"x","email":"x","vehicle":"Infinity M35"}},{"type":"Feature","geometry":{"type":"Point","coordinates":["-81.972443","28.908287"]},"properties":{"gx_id":"89","address":"The Villages, Lake Sumter Landing, Lady Lake Orlando FL 32162","name":"x","phone":"x","email":"x","vehicle":"VW Bettle"}}]}

这是我的Ajax

function sendBatch(tableID, data){
dataString = data;
console.log(dataString);
var url = "https://www.googleapis.com/mapsengine/v1/tables/"+tableID+"/features/batchInsert";
jQuery.ajax({
type: "POST",
url: url,
data: dataString,
contentType: 'application/json',
headers: {
'Authorization': 'Bearer ' + authResult.access_token
},
success: function(response) {
// Log the details of the Map.
console.log(response);
},
error: function(response) {
response = JSON.parse(response.responseText);
console.log("Error: ", response);
}
});
}

这是我得到的错误

{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "The value is invalid.",
"locationType": "parameter",
"location": "id"
}
],
"code": 400,
"message": "The value is invalid."
}
}

我正在传递功能,所以我不明白为什么它会出现问题。有人有什么想法吗?

如果不知道要发送到API的数据/dataString,很难判断,但错误显示位置"id"处的"值无效"。您在"id"列中提供的值很可能对架构不正确。也就是说,如果您设置了一个名为id的字符串类型的列,并且您正在发送一个double(例如),那么您将收到该错误。

需要注意的一点是,API要求整数作为带引号的字符串发送,以避免精度损失。详细信息见文档。


EDIT:我已经成功地设置了一个表并插入了您的JSON,没有任何问题。错误指向一个位置"id",我认为它对应于您在URL中提供的表id。我说过它可能是一个功能属性,但位置看起来像"features[0].properties.id"。该错误还指定了"parameter"的"locationType"。你能检查你的tableID参数并确保它有效吗?

最新更新