# jSON query in NEST 5.0

**URL:** https://discuss.elastic.co/t/json-query-in-nest-5-0/70164
**Category:** Elasticsearch
**Created:** [December 28, 2016, 9:31pm UTC](https://discuss.elastic.co/t/json-query-in-nest-5-0/70164 "2016-12-28T21:31:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![iluvcode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iluvcode/32/24929_2.png) [@iluvcode](https://discuss.elastic.co/u/iluvcode)
#### Post date: [December 28, 2016, 9:31pm UTC](https://discuss.elastic.co/t/json-query-in-nest-5-0/70164/1 "2016-12-28T21:31:54Z")

</div>

In debugger i was able to look at the jSON query that is being sent to Elasticsearch in version 1.7.  
After upgrading to v5.0, i cannot find the jSON query that is being sent to Elasticsearch.

---

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [December 30, 2016, 11:54pm UTC](https://discuss.elastic.co/t/json-query-in-nest-5-0/70164/2 "2016-12-30T23:54:57Z")

</div>

You can see the json sent to and received from Elasticsearch by [setting a few options on `ConnectionSettings`](https://www.elastic.co/guide/en/elasticsearch/client/net-api/5.x/connecting.html#complex-logging):

```
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));

var connectionSettings = new ConnectionSettings(pool)
        // pretty print all requests and responses to Elasticsearch
        .PrettyJson()
        // buffer the request and response bytes in MemoryStream
        .DisableDirectStreaming()
        // a delegate to run when a request completes. Use this to capture 
        // request and response information
        .OnRequestCompleted(response =>
            {
                // log out the request
                if (response.RequestBodyInBytes != null)
                {
                    Console.WriteLine(
                        $"{response.HttpMethod} {response.Uri} \n" +
                        $"{Encoding.UTF8.GetString(response.RequestBodyInBytes)}");
                }
                else
                {
                    Console.WriteLine($"{response.HttpMethod} {response.Uri}");
                }

                Console.WriteLine();

                // log out the 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(connectionSettings);

```

Now with this in place, we can capture the request and responses. `.DisableDirectStreaming()` can also be set on a per-request basis so that request and response bytes are only buffered when necessary, as doing so will have an impact on performance.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 27, 2017, 11:55pm UTC](https://discuss.elastic.co/t/json-query-in-nest-5-0/70164/3 "2017-01-27T23:55:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
