I\'m currently having a really weird issue with calling one REST service from inside another one and I could really use a hand in working out what I\'m doing wrong.
A HTTP415 means Unsupported Media Type. What that means is that isUsernameAvailable
expects input in JSON format, but that isn't what it is getting.
Try explicitly adding Content-Type: application/json
header to your HTTP request by doing the following:
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<String>(requestJson,headers);
restTemplate.put(uRL, entity);
Use RestTemplate.exchange mentioned below :
ResponseEntity<String> response = RestTemplate.exchange(EndPointURL, HttpMethod.GET/POST/PUT/DELETE, HttpEntity/headers, URI-Variables)
The input paramater's are described below :
EndpointURL -- SOAP End point URL ,that the REST service has to consume.
HTTPMethod -- Method Type such as GET ,PUT ,POST ,DELETE etc.
HTTPEntity -- Soap requires for mandatory sender headers.Make sure that you set your header(s) name and value as key-Value pair in HTTP headers.
URI-Variables -- (Object... urivariables) such as String.class ,Integer.class
You should also put the connectTimeout , isSSLDisabled, responseCached in the constructor while generating request to restTemplate.