I am completely new in RestTemplate and basically in the REST APIs also. I want to retrieve some data in my application via Jira REST API, but getting back 401 Unauthorised.
Use setBasicAuth
to define credentials
HttpHeaders headers = new HttpHeaders();
headers.setBasicAuth("myUsername", myPassword);
Then create the request like you prefer.
Example:
HttpEntity request = new HttpEntity(headers);
ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET,
request, String.class);
String body = response.getBody();