我使用Spring框架的RestTemplate創建了Java中的REST客戶端。如何從RestTemplate postForLocation獲取STRING響應?
一切都很好,直到我必須做一個職位postForLocation。
我有權訪問的web服務返回一個帶有關於POST操作信息的json。
在PHP中很好,但我真的不明白如何在Java中使用RestTemplate。
public String doLogin()
{
Map<String, String> args = new HashMap<String, String>();
args.put("email", AUTH_USER);
args.put("token", AUTH_PASS);
String result = restTemplate.postForLocation(API_URL + "account/authenticate/?email={email}&token={token}", String.class, args);
return result;
}
這將返回NULL。
使用相同的代碼,但使用getForObject(當然,更改URL爲正確的東西)我有一個完整的響應。
因此...如何從postForLocation獲得RESPONSE?
Obs .:對不起,如果這個問題是愚蠢的。我是Java的初學者
你應該發佈「答案」作爲答案。 – Jaanus 2013-03-27 21:25:52
謝謝......第一次我需要這樣做:] – Alexandre 2013-03-27 21:27:24