2条回答 默认 最新
- A智丨勇灬 2019-09-04 10:08关注
MultiValueMap<String, Object> requestBody = new LinkedMultiValueMap<>(); CloseableHttpClient httpClient = HttpClientBuilder.create().build(); HttpPost httpPost = new HttpPost(boostpayConfiguration.getUrl()); String jsonString = JSON.toJSONString(returnMap); StringEntity entity = new StringEntity(jsonString, "UTF-8"); httpPost.setEntity(entity); httpPost.setHeader("Content-Type", "application/json;charset=utf8"); httpPost.setHeader("Authorization", "Bearer " + boostPayVO.getApiToken()); CloseableHttpResponse response = null; // 由客户端执行(发送)Post请求 response = httpClient.execute(httpPost); // 从响应模型中获取响应实体 HttpEntity responseEntity = response.getEntity(); log.info("=====响应状态为:{}", response.getStatusLine()); if (responseEntity != null) { log.info("=====响应内容长度为:{}", responseEntity.getContentLength()); String responseJson = EntityUtils.toString(responseEntity); log.info("=====响应内容为:{}", responseJson); return JSON.parseObject(responseJson, Map.class); }
自己动手风衣足食
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用