我可以通过QueryString sql参数插入行。 https://developers.google.com/fusiontables/docs/v1/reference/query/sql?hl=ja
但参考文档描述了您可以使用sql参数作为POST的主体来插入行。我不能。我该怎么办? https://developers.google.com/fusiontables/docs/v1/using?hl=ja#insertRow
首先参考描述了QueryString所需的sql参数。我通过在QueryString中省略sql得到了错误400。使用QueryString有限制(URL长度)。我想在POST主体中插入很多行。
请求:
POST https://www.googleapis.com/fusiontables/v1/query?access_token={my access token} HTTP/1.1
Content-Type: application/json
sql=INSERT INTO 1JOgUG5QWE5hybrDAd2GX3yfjVCGoM6u7WkSVDok ('_id', '_count', 'start_time', 'end_time', 'counts', 'start_plaece', 'end_place', 'distance', 'average_speed', 'send_flag', 'time_span', 'train_type', 'calories', 'weight', 'status', 'map_url', 'rally_id' ) VALUES ('-1', '0', '2013/01/19 09:00:00.000', '2013/01/19 12:34:56.000', '9876', 'Tokorozawa3', 'iidabashi2', '45678', '67', '0', '986532', '1', '389', '77.70', '0', 'http://www.google.com/', '3');
响应:
body {
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: sql",
"locationType": "parameter",
"location": "sql"
}
],
"code": 400,
"message": "Required parameter: sql"
}
}
答案 0 :(得分:1)
文档有问题,并且缺少一些细节。
您可以在请求网址中使用sql = ... 参数。 ContentType标头通常是application / json,但API也可能接受其他标头。在这种情况下,您的网址长度限制为2048个字符。
你也可以在POST正文中使用sql = ... 。在这种情况下,您必须设置 ContentType必须是application / x-www-form-urlencoded 。在一个请求中,您只能使用500个INSERT语句。
另一种选择是使用importRows方法。在这里,您将使用 CSV作为POST正文。在此方法中,您受到100MB上传数据的限制。 ContentType必须是" application / octet-stream" 。 更多详情:importRows reference