1

以下代码导致 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] =>
)
4

2 回答 2

2

看了之后就这么简单,“TEXT”不是有效的列类型。您需要改用“STRING”。

于 2013-05-14T10:19:55.813 回答
0

isExportable 位也是创建表时的必需参数 ( https://developers.google.com/fusiontables/docs/v1/reference/table/insert )。当你设置它时会发生什么?

于 2013-05-13T22:21:53.583 回答