Apache 구성 요소 (4.3) - http://hc.apache.org/httpcomponents-client-4.3.x/tutorial/html/fluent.html의 예를 사용하여 http POST를 작성하려고합니다. 불행히도 해결 방법을 찾을 수 없다는 오류가 나타납니다.아파치 구성 요소의 유창을 사용하는 방법
이전에 HttpClient
을 사용 했으므로 구성 요소를 처음 사용합니다. 여기
String address = "http://1.1.1.1/services/postPositions.php";
String response = Request.Post(address)
.bodyString("Important stuff", ContentType.DEFAULT_TEXT)
.execute().returnContent().asString();
System.out.println(response);
을 내가 그 코드를 실행할 때 예외가 얻을 : 나뿐만 아니라 양식 요소를 구축하고를 사용하는 것을 시도했다
Exception in thread "main" java.lang.IllegalStateException: POST request cannot enclose an entity
at org.apache.http.client.fluent.Request.body(Request.java:299)
at org.apache.http.client.fluent.Request.bodyString(Request.java:331)
at PostJson.main(PostJson.java:143)
을 bodyForm()
방법 -하지만 같은 오류가 발생합니다.
문구가 명확하지 않습니다. 당신은 당신에게 *** 같은 문제가 있다고 말하고 있습니까? 그리고 이것은 해결책입니까? 아니면 당신은 똑같은 문제가 있다고 말하면서도 여전히 해결책을 찾고 있습니까? –
명확한 답변. – swKK
이 답변과 다른 대답이 모두 도움이되었습니다. 그러나이 대답이 나에게 해결 방법을 가져다 줬기 때문에 이것을 바로 대답으로 표시하기로 결정했습니다 .-) –