ExposeRawResponse
is now DisableDirectStreaming
.
The documentation for NEST 2.x on Connecting provides an example of configuring inspection of all requests and responses using OnRequestCompleted
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(connectionPool, new InMemoryConnection())
.DefaultIndex("default-index")
.DisableDirectStreaming()
.OnRequestCompleted(response =>
{
// log out the request and the request body, if one exists for the type of request
if (response.RequestBodyInBytes != null)
{
Console.WriteLine(
$"{response.HttpMethod} {response.Uri} \n" +
$"{Encoding.UTF8.GetString(response.RequestBodyInBytes)}");
}
else
{
Console.WriteLine($"{response.HttpMethod} {response.Uri}");
}
// log out the response and the response body, if one exists for the type of response
if (response.ResponseBodyInBytes != null)
{
Console.WriteLine($"Status: {response.HttpStatusCode}\n" +
$"{Encoding.UTF8.GetString(response.ResponseBodyInBytes)}\n" +
$"{new string('-', 30)}\n");
}
else
{
Console.WriteLine($"Status: {response.HttpStatusCode}\n" +
$"{new string('-', 30)}\n");
}
});
var client = new ElasticClient(settings);
If you just want to inspect the response ad-hoc, then set DisableDirectStreaming
and then get the string from the response body bytes
Encoding.UTF8.GetString(response.ResponseBodyInBytes)