restTemplate.postForObject接口请求
一、post请求【接口请求参数有params】
RestTemplate restTemplate = new RestTemplate();
String url =domesticAPP_url_Online+"readBook/listReadBookByCode";
JSONObject paramsJ = JSON.parseObject(params);
Map map = new HashMap();
map.put("token",LoginToken);
MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap();
postParameters.add("params", JSON.toJSONString(map)); //http接口请求类型为json格式
/*调用接口*/
HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(postParameters,headers);
JSONObject response = restTemplate.postForObject(url, request, JSONObject.class);
浙公网安备 33010602011771号