Here is my C# code:
try
{
var credentials = new BasicAuthenticationCredentials(configuration["Elastic:Username"], configuration["Elastic:Password"]);
var pool = new CloudConnectionPool(configuration.GetConnectionString("CacheConnection"), credentials);
var settings = new ConnectionSettings(pool)
.DefaultMappingFor<Facility>(m => m.IndexName("facilities"))
.DefaultMappingFor<TokenCacheEntry>(m => m.IndexName("tokens"))
.DefaultMappingFor<VideoModel>(m => m.IndexName("videos"))
.DefaultMappingFor<SFUser>(m => m.IndexName("users"))
.DefaultIndex("defaultindex");
_client = new ElasticClient(settings);
var response = _client.Ping();
if (!response.IsValid)
{
throw new Exception();
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
Error received:
Invalid NEST response built from a unsuccessful (401) low level call on HEAD: /
Audit trail of this API call:
- [1] BadResponse: Node: https://1642af63f1024125824fbb577713e41c.westus2.azure.elastic-cloud.com:9243/ Exception: PipelineException Took: 00:00:00.9987949
OriginalException: Elasticsearch.Net.ElasticsearchClientException: Could not authenticate with the specified node. Try verifying your credentials or check your Shield configuration.. Call: Status code 401 from: HEAD / ---> Elasticsearch.Net.PipelineException: Could not authenticate with the specified node. Try verifying your credentials or check your Shield configuration.
at Elasticsearch.Net.RequestPipeline.ThrowBadAuthPipelineExceptionWhenNeeded(IApiCallDetails details, IElasticsearchResponse response) in C:\Source\elasticsearch-net-7.x\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 573
at Elasticsearch.Net.RequestPipeline.CallElasticsearch[TResponse](RequestData requestData) in C:\Source\elasticsearch-net-7.x\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 168
at Elasticsearch.Net.Transport`1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters) in C:\Source\elasticsearch-net-7.x\src\Elasticsearch.Net\Transport\Transport.cs:line 73
--- End of inner exception stack trace ---
Audit exception in step 1 BadResponse:
Elasticsearch.Net.PipelineException: Could not authenticate with the specified node. Try verifying your credentials or check your Shield configuration.
at Elasticsearch.Net.RequestPipeline.ThrowBadAuthPipelineExceptionWhenNeeded(IApiCallDetails details, IElasticsearchResponse response) in C:\Source\elasticsearch-net-7.x\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 573
at Elasticsearch.Net.RequestPipeline.CallElasticsearch[TResponse](RequestData requestData) in C:\Source\elasticsearch-net-7.x\src\Elasticsearch.Net\Transport\Pipeline\RequestPipeline.cs:line 168
at Elasticsearch.Net.Transport`1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters) in C:\Source\elasticsearch-net-7.x\src\Elasticsearch.Net\Transport\Transport.cs:line 73
Request:
<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
Response:
<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
I am able to successfully connect via Postman using my 'elastic' user credentials but when I provide the same credentials to Nest I can't connect.