Hi,
I am trying to authenticate to ES in java. But getting malformed host header exception.
Someone please help here.
final CredentialsProvider credentialsProvider =
new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials("", ""));
RestClientBuilder builder = RestClient.builder(
new HttpHost(elasticSearchHost, elasticSearchPort, "https"))
.setDefaultHeaders(new Header[]{new BasicHeader("Authorization","ApiKey "+"")})
.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(
HttpAsyncClientBuilder httpClientBuilder) {
return httpClientBuilder
.setDefaultCredentialsProvider(credentialsProvider);
}
});
RestHighLevelClient client = new RestHighLevelClient(
builder);