I am trying to add a header into the restTemplate, with one of its methods exchange
.
In header i am putting the token access, which we can access with.
The error i am getting is that i am not Authorized, 401 status is giving back . Any advices what i am doing wrong?
HttpHeaders headersAuth = new HttpHeaders();
headersAuth.set(HttpHeaders.ACCEPT,MediaType.APPLICATION_JSON_VALUE);
HttpEntity<?> entityAuth = new HttpEntity<>(headersAuth);
String urlTemplateAuth = UriComponentsBuilder.fromHttpUrl("some url")
.encode()
.toUriString();
Map<String,String> queryParamsAuth = new HashMap<>();
queryParamsAuth.put("Authorization",tokenValue); //here is my token access
ResponseEntity <UserGetPhoneDto> userGetPhoneDtoResponseEntity = restTemplate.exchange(urlTemplateAuth,HttpMethod.GET,entityAuth,UserGetPhoneDto.class,queryParamsAuth);
//here i am getting error of 401 status