2012-12-16 129 views
0

我的代碼:拒絕授權使用融合表API

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個小時以來我的腦袋一塌糊塗。

回答

1

你的URI看起來不對 - 「tableid」應該替換爲你的表的實際ID。

+0

我不想讓我的桌面公開,爲什麼我沒有寫這個。 – bhalkian

相關問題