Unable to connect to Cloud Platform via Nest

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:

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.

It looks like the credentials set in the client are not correct.

If you spin up a local proxy like Fiddler, you'll be able to capture and inspect the Authorization header being sent.

I pulled a dumb and pasted the password in twice. Even when I pulled the value from Fiddler it looked correct and I didn't spot the issue until I tried to log into my Kibana instance with the password I was sending and realized I had pasted it twice.