我正在尝试向端点发送同步POST,如下所示:
但似乎我的httpClinet发布了一个空白数据。我在这里做错了什么?
这是httpClinetPost postTo实现:
public static String postTo(String stringToPass)
{
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost(some url);
request.setEntity(new ByteArrayEntity(stringToPassing);
HttpResponse response = httpClient.execute(request);
int res = response.getStatusLine().getStatusCode();
if (res == 401) {
throw new IOException(res);
} else if (res != 200) {
throw new IOException(res);
}
String responseString = EntityUtils.toString(response.getEntity());