0

私のコード:

public class restletexample {

    String URI = "https://www.googleapis.com/upload/fusiontables/v1/tables/tableid/import";

    HashMap<String, String> urlVariables = new HashMap<String, String>();

    String column = "'Moth', '30', '2012','efef','efefef'";

    public void testrestlet() {

        urlVariables.put("key=", "KEY");

        RestTemplate restTemplate = new RestTemplate();

        restTemplate.postForLocation(URI, column, urlVariables);

    }

    public static void main(String args[]) {

        restletexample rst = new restletexample();
        rst.testrestlet();

    }

}

例外 :

Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 401 Unauthorized

APIコンソールでキーを生成し、同じを使用しています。なぜグーグルが私のリクエストを承認していないのかわかりません。助けが必要です...過去4時間以来私の頭を壊しています。

4

1 に答える 1

1

URI が間違っているようです。「tableid」をテーブルの実際の ID に置き換える必要があります。

于 2012-12-17T18:40:03.400 に答える