私はHttpConnectを使用していて、サーバーから何らかのトークンを取得しようとしています。私は応答を取得しようとするたびに。しかし、そのは常にあなたも、私は多くの異なる方法で"HTTPエラー411を解決する方法。要求にはチャンクを入れたり、内容の長さを指定する必要があります。 in java
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod(method);
conn.setRequestProperty("X-DocuSign-Authentication", httpAuthHeader);
conn.setRequestProperty("Accept", "application/json");
if (method.equalsIgnoreCase("POST")) {
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", Integer.toString(body.length()));
conn.setDoOutput(true);
}
status = conn.getResponseCode(); // triggers the request
if (status != 200) { //// 200 = OK
errorParse(conn, status);
return;
}
InputStream is = conn.getInputStream();
HttpClient
を使用して作るのコードである。しかし、私はHttpClientをその作業を使用して同じことをやろう場合。 –HttpClient httpclient = new DefaultHttpClient(); –
どのような方法を使用していますか?これはPUTに起こるはずです。 PUTをチェックするために 'if(method.equalsIgnoreCase(" POST "))'を変更すると、あなたの問題が解決するかもしれません。 –