# IElasticClient.CatHealth() works OK locally, but fails in json parsing when talking to elastic cloud instance

**URL:** <https://discuss.elastic.co/t/ielasticclient-cathealth-works-ok-locally-but-fails-in-json-parsing-when-talking-to-elastic-cloud-instance/55431>\
**Category:** Elasticsearch\
**Created:** [July 13, 2016, 5:02pm UTC](https://discuss.elastic.co/t/ielasticclient-cathealth-works-ok-locally-but-fails-in-json-parsing-when-talking-to-elastic-cloud-instance/55431 "2016-07-13T17:02:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tylersa](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@tylersa](https://discuss.elastic.co/u/tylersa)\
**Post date:** [July 13, 2016, 5:02pm UTC](https://discuss.elastic.co/t/ielasticclient-cathealth-works-ok-locally-but-fails-in-json-parsing-when-talking-to-elastic-cloud-instance/55431/1 "2016-07-13T17:02:25Z")

</div>

Hi gang,

Context:  
ElasticSearch 2.3.4  
C#/.Net apps using NEST & [Elasticsearch.Net](http://Elasticsearch.Net) 2.3.3 (next hop is of client nuget package is to 2.4.x which forces us to upgrade Newtonsoft.Json, so I'd like to avoid that if possible for now).

I have ES 2.3.4 running locally and have a suite of integration tests covering functionality leveraged by our application. All tests are passing nicely.

We're now getting ready to take the cloud-hosted step, so I set up a trial account for elastic cloud, created a cluster (also 2.3.4), set the access creds configuration (left at defaults that were generated), and then configured and aimed our tests at the new cloud-hosted cluster...

... all my indexing and search-based tests are still passing nicely.. but anything that tries to call the "Cat\*"-related methods (eg. IElasticClient.CatHealth()) is failing with exceptions like this:

Result Message:   
Test method IntegrationTests.ElasticSearchFtsTests.That\_Cluster\_Is\_Accessible threw exception:  
Elasticsearch.Net.UnexpectedElasticsearchClientException: Error converting value 1468428886 to type 'System.Collections.Generic.IEnumerable`1[Nest.CatHealthRecord]'. Path '', line 1, position 10. ---> Newtonsoft.Json.JsonSerializationException: Error converting value 1468428886 to type 'System.Collections.Generic.IEnumerable`1[Nest.CatHealthRecord]'. Path '', line 1, position 10. ---\> System.ArgumentException: Could not cast or convert from System.Int64 to System.Collections.Generic.IEnumerable`1[Nest.CatHealthRecord].

... the same client code, same ES server version handles the result fine when run locally, but barfs trying to parse the results from "\_cat/health" when aimed at the hosted cluster.. the results of \_cat/health (via Sense) look comparable in both cases and are definitely not Json... so why it's being parsed as Json is a mystery, and understandable that the parsing is failing... but why is this handled gracefully in the local hosting scenario and not in the cloud hosted scenario?

Thanks for your help,

Tyler

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [July 14, 2016, 8:20am UTC](https://discuss.elastic.co/t/ielasticclient-cathealth-works-ok-locally-but-fails-in-json-parsing-when-talking-to-elastic-cloud-instance/55431/2 "2016-07-14T08:20:09Z")

</div>

Hi Tyler,  
this seems to be a problem around headers being filtered out by Elastic Cloud. There's also an issue opened for it: [https://github.com/elastic/elasticsearch-net/issues/2076](https://github.com/elastic/elasticsearch-net/issues/2076) . We are discussing a fix for this, you can track progress on the issue that I posted.

Cheers  
Luca

---

<div class="post-metadata">

**Author:** ![Martijn\_Laarman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/martijn_laarman/32/4410_2.png) [@Martijn\_Laarman](https://discuss.elastic.co/u/Martijn_Laarman)\
**Post date:** [July 14, 2016, 8:27am UTC](https://discuss.elastic.co/t/ielasticclient-cathealth-works-ok-locally-but-fails-in-json-parsing-when-talking-to-elastic-cloud-instance/55431/3 "2016-07-14T08:27:50Z")

</div>

Hi this is a known issue:

> <https://github.com/elastic/elasticsearch-net/issues/2076>

Elastic Cloud strips the accept header and NEST wants the cat data in json form.

You can use the lowlevel cat API instead to circumvent the problem

```auto
var client = new ElasticClient(new Uri("http://localhost:9200"));
var catHealth = client.LowLevel.CatHealth<string>();
//catHealth.Body will hold the string as returned by default by elasticsearch

```

or just use the `.ClusterHealth()` endpoint to get the same information in a more typed fashion

```auto
var clusterHealth = client.ClusterHealth();

```

---

<div class="post-metadata">

**Author:** ![tylersa](https://avatars.discourse-cdn.com/v4/letter/t/59ef9b/32.png) [@tylersa](https://discuss.elastic.co/u/tylersa)\
**Post date:** [July 19, 2016, 5:13pm UTC](https://discuss.elastic.co/t/ielasticclient-cathealth-works-ok-locally-but-fails-in-json-parsing-when-talking-to-elastic-cloud-instance/55431/4 "2016-07-19T17:13:25Z")

</div>

Hi Martijn, thanks for the response. Your workaround is what had fallen back to and it is working nicely. Thanks again,

Tyler

---

<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:** [July 5, 2017, 10:34pm UTC](https://discuss.elastic.co/t/ielasticclient-cathealth-works-ok-locally-but-fails-in-json-parsing-when-talking-to-elastic-cloud-instance/55431/5 "2017-07-05T22:34:20Z")

</div>


