尝试model
从代码中删除,因为我可以在你的curl请求中看到你没有使用模型属性,一切正常.试试这个:
public static void main(String[] args) { final String uri = "url"; RestTemplate restTemplate = new RestTemplate(); // Add the Jackson message converter restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); // create request body String input = "{\"name\":\"name\",\"email\":\"email@gmail.com\"}"; // set headers HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.set("Authorization", "Basic " + "xxxxxxxxxxxx"); HttpEntityentity = new HttpEntity (input, headers); // send request and parse result ResponseEntity response = restTemplate .exchange(uri, HttpMethod.POST, entity, String.class); System.out.println(response); }