我需要使用apache HttpClient +4将数据发布到我的api,静态服务中,但是我无法正常工作,我已经尝试过:
String url = "http://localhost:6768/rest/cmp/prods";
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("key", "value"));
EntityBuilder entityBuilder = EntityBuilder.create().setParameters(nameValuePairs);
HttpPost post = new HttpPost(url);
post.setEntity(entityBuilder.build());
CloseableHttpClient httpClient = HttpClients.custom().build();
CloseableHttpResponse response = httpClient.execute(post);
返回
HTTP / 1.1 400错误请求
如何使用apache httpclient将数据发布到我的Restful服务?
致谢