I am using RestTemplate to make a POST request to an external endpoint
RestTemplate restTemplate = new RestTemplate();
final String url = "https://jsonplaceholder.typicode.com/users";
String jsonData = "{"title":"foo", :"body"::"bar",:"userId":1}";
//Set Headers
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
//Create HttpEntity object
HttpEntity<String> requestEntity = new HttpEntity<>(jsonData,headers);
ResponseEntity<String> response = restTemplate.exchange(url,HttpMethod.POST,requestEntity,String.class);
return response.getBody();
i’m getting this error
I/O error on POST request for “url”: Connection timed out
i tried the solutions on similar stackoverflow questions using ClosableHttpClient it didn’t work, any help or guidance is appreciated.