-----------------------------------------------------------------------------
body内容:
{
"name":"mark",
"orgIds": ["111","222"],
}
RestTemplate调用POST接口示例:
String url = "127.0.0.1:8080/resources?id=1";
JSONObject json = new JSONObject();
json.put("orgIds", Arrays.asList("1111","222"));
json.put("name", "mark");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON_UTF8);
headers.add("Accept", org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE);
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
HttpEntity<JSONObject> entity = new HttpEntity<>(json, headers);
String result = new RestTemplate().postForObject(url, entity, String.class);
JSONObject JsonObject = JSONObject.parseObject(result);
JsonObject = JSON.parseObject(JsonObject.getString("content"));