我们正试图通过Spring Rest Template访问Lithium Rest Api(它的https网站),如下所示
`String plainCreds = lswUserName + ":" + lswPassword;
byte[] plainCredsBytes = plainCreds.getBytes();
byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
String base64Creds = new String(base64CredsBytes);
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic " + base64Creds);
HttpEntity<String> request = new HttpEntity<String>(headers);
ResponseEntity<String> sRawResp = restTemplate.exchange(completeURL.toString(), HttpMethod.GET, request, String.class);'
以上代码总是给出
org.springframework.web.client.HttpClientErrorException: 401 Unauthorized Exception
通过邮递员调用相同的Web服务时没有问题,但是当通过java代码访问时,获得上述401未经授权的异常