RestTemplate调用第三方接口
作者:互联网
String url="http://10.10.14.XX:8080/sharePoint/deleteFile";
RestTemplate client =new RestTemplate();
HttpHeaders headers =new HttpHeaders();// 请勿轻易改变此提交方式,大部分的情况下,提交方式都是表单提交 headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);// 封装参数,千万不要替换为Map与HashMap,否则参数无法传递
MultiValueMap params=new LinkedMultiValueMap();// 也支持中文params.add("username","用户名");
params.add("fileName", "20201215162310_视频.mp4");
HttpEntity requestEntity =new HttpEntity(params, headers);// 执行HTTP请求
ResponseEntity response = client.exchange(url, HttpMethod.POST, requestEntity, Json.class);// 输出结果
System.out.println(response.getBody());
标签:调用,RestTemplate,接口,headers,add,params,new,HttpHeaders 来源: https://www.cnblogs.com/gykuang/p/14250967.html