Skip to content
Advertisement

Java Exception: Unauthorized: 401

I’m getting the error: Exception: org.springframework.web.client.HttpClientErrorException$Unauthorized: 401, when trying to connect to Jira through HttpHeader, and the credentials are configured in a configserver file, which would be this:

JavaScript

And the method where I command to call the file above and where I get the error on the line ResponseEntity<String> result = restTemplate.exchange(url, HttpMethod.GET,this.requestEnt, String.class);, would be this:

JavaScript

In fact, when I run the debug and check the credentials, it brings them up without a problem. I’ve already searched, tried most of the links on this page and I can’t find the solution. Any help would be appreciated in this case, thanks in advance.

Advertisement

Answer

When you define your authorization header you concat your key with « Basic » without adding a white space.

JavaScript

Instead of :

JavaScript

Maybe it’s just that.

Edit : The answer was to add StandardCharsets.UTF-8 to the String constructor.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement