本文使用的HttpHeaders为org.springframework.http.HttpHeaders
本文使用的请求类型为:POST
示例:
// build uri
URI uri = new URIBuilder().setScheme("http").setHost(ip).setPort(port).setPath("/platform/service")
.addParameter("user", RUYIN_USER_ID1)
.addParameter("service", service)
.addParameter("data", FastJsonConvertUtil.convertObjectToJSON(data))
.build();
// build http headers
HttpHeaders headers = new HttpHeaders();
headers.add("x-auth-token","123");
// send request and get response
String result = restTemplate.postForObject(uri, new HttpEntity<String>(headers), String.class);