对端点的同步POST不会发布数据 - java

时间:2015-04-13 03:02:41

标签: java apache post jsonobject

我正在尝试向端点发送同步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());

0 个答案:

没有答案