Get请求,参数为@RequestBody的http请求

Get请求,参数为@RequestBody的http请求

  • 调用接口

调用接口

 public static String HttpClientBuilderGet(String uri,String body) {
	    final CloseableHttpClient httpClient = HttpClientBuilder.create().build();
	    final HttpEntityEnclosingRequestBase httpGet = new HttpGetOfBody(uri);
	    final InputStream inputStream = IOUtils.toInputStream(body, Charset.defaultCharset());
	    httpGet.addHeader("Content-Type","application/json");
	    httpGet.setEntity(new InputStreamEntity(inputStream));
	    try {
	        final CloseableHttpResponse response = httpClient.execute(httpGet);
			return IOUtils.toString(response.getEntity().getContent(),Charset.defaultCharset());
	    } catch (IOException e) {
			return e.getMessage();
	    }
	}

你可能感兴趣的:(java)