このコードを実行すると、httpResponseで応答を取得します。ヘッダーの正しいバイト数を報告しています。しかし、体は空です。.getBody()を呼び出すと、nullになります。
ヘッダ:
<200 OK,{Date=[Thu, 29 Nov 2012 16:26:06 GMT], Server=[Apache], Vary=[Accept-Encoding], Content-Length=[5072], Keep-Alive=[timeout=10, max=100], Connection=[Keep-Alive], Content-Type=[text/html]}>
私は何が間違っているのですか?
String url = new String("http://www.myurl.com/scripts/json/v1/slipmanager.php");
MultiValueMap<String, Object> formData = new LinkedMultiValueMap<String, Object>();
formData.add("username", userName);
formData.add("password", md5(userPassword));
formData.add("method", "getslips");
RestTemplate template = new RestTemplate(true);
template.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(new MediaType("multipart", "form-data"));
template.getMessageConverters().add(new StringHttpMessageConverter());
HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<MultiValueMap<String, Object>>(formData, requestHeaders);
ResponseEntity<?> httpResponse = null;
try
{
httpResponse = template.exchange(url, HttpMethod.POST, request, null);
String tmp = (String) httpResponse.getBody();
//THIS IS WHERE THE BODY IS NULL
}
catch (Exception e)
{
Log.e("POST", e.getMessage(), e);
}