以下代码导致400 Bad Request ...你能看到任何明显的问题吗?
$column = new Google_Column();
$column->setName('foo');
$column->setType('TEXT');
$table = new Google_Table();
$table->setName('bar');
$table->setColumns(array($column));
// $client below is a successfully authenticated Google_Client instance
$service = new Google_FusiontablesService($client);
$result = $service->table->insert($table); // 400 Bad Request exception thrown
Google_Client通过“服务帐户”进行身份验证,我可以运行其他请求,例如$service->query->sql()
成功。
Google API客户端版本为0.6.2(最新)。
感谢。
更新:请求对象转储:
Google_HttpRequest Object
(
[batchHeaders:Google_HttpRequest:private] => Array
(
[Content-Type] => application/http
[Content-Transfer-Encoding] => binary
[MIME-Version] => 1.0
[Content-Length] =>
)
[url:protected] => https://www.googleapis.com/fusiontables/v1/tables
[requestMethod:protected] => POST
[requestHeaders:protected] => Array
(
[content-type] => application/json; charset=UTF-8
[content-length] => 162
[authorization] => Bearer someHashHere
)
[postBody:protected] => {"columns":[{"name":"Project","type":"TEXT"}],"description":"Created on 2013-05-14 10:41:44","isExportable":"true","name":"foobar"}
[userAgent:protected] => My app name google-api-php-client/0.6.0
[responseHttpCode:protected] =>
[responseHeaders:protected] =>
[responseBody:protected] =>
[accessKey] =>
)
答案 0 :(得分:2)
看到之后它就这么简单," TEXT"不是有效的列类型。你需要使用" STRING"代替。
答案 1 :(得分:0)
创建表(https://developers.google.com/fusiontables/docs/v1/reference/table/insert)时,isExportable位也是必需参数。设置时会发生什么?