Add my custom http header to Spring RestTemplate request / extend RestTemplate

You can pass custom http headers with RestTemplate exchange method as below. HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(new MediaType[] { MediaType.APPLICATION_JSON })); headers.setContentType(MediaType.APPLICATION_JSON); headers.set(“X-TP-DeviceID”, “your value”); HttpEntity<RestRequest> entityReq = new HttpEntity<RestRequest>(request, headers); RestTemplate template = new RestTemplate(); ResponseEntity<RestResponse> respEntity = template .exchange(“RestSvcUrl”, HttpMethod.POST, entityReq, RestResponse.class); EDIT : Below is the updated code. This link has … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)