Reputation: 41
I've got a problem while trying to connect to an elasticsearch API. The API expect an bearer token, but the NEST lybrary only provides a basic authentication and I've got to pass a custom header as well. So, did anybody have to face this problem?? How to pass custom headers?!
Thanks
Upvotes: 1
Views: 2731
Reputation: 41
Actually I was getting a mistaken concept. Actually I'm interacting with an API wich encapsolate the elasticsearch and just use the elasticsearch query sintax, so I didn't need to use NEST, the elasticsear package, to connect with it. And I just got to interact it with a simple http call.
Anyway, thanks Russ
Upvotes: 0
Reputation: 125528
You can add headers that should be added to all requests on ConnectionSettings
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings = new ConnectionSettings(pool)
.GlobalHeaders(new NameValueCollection
{
{ "Authorization", "Bearer fnoi3nfion3fn00jr0j1r0" }
});
var client = new ElasticClient(connectionSettings);
Upvotes: 6
Reputation: 24843
you can add any header to your request:
req.Headers.Add("CustomeKey", CustomeData);
Upvotes: -1