# Index binary(blob) file with NEST

**URL:** <https://discuss.elastic.co/t/index-binary-blob-file-with-nest/60233>\
**Category:** Elasticsearch\
**Created:** [September 11, 2016, 8:58am UTC](https://discuss.elastic.co/t/index-binary-blob-file-with-nest/60233 "2016-09-11T08:58:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dror\_Musahy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dror_musahy/32/19113_2.png) [@Dror\_Musahy](https://discuss.elastic.co/u/Dror_Musahy)\
**Post date:** [September 11, 2016, 8:58am UTC](https://discuss.elastic.co/t/index-binary-blob-file-with-nest/60233/1 "2016-09-11T08:58:18Z")

</div>

please advise what I miss here:

form sense this working:  
POST /stackoverflow/docA  
{  
"name": "Some binary blob",  
"blob": "U29tZSBiaW5hcnkgYmxvYg=="  
}

result in Sense brows is:  
{  
"\_index": "stackoverflow",  
"\_type": "docA",  
"\_id": "100002",  
"\_version": 2,  
"\_score": 1,  
"\_source": {  
"name": "Some binary blob",  
"blob": "U29tZSBiaW5hcnkgYmxvYg=="  
}  
}

But from C# not:

Poco entity:  
public class Attachment  
{  
[JsonProperty("name")]  
public string Name { get; set; }

```
    [Binary]
    [JsonProperty("blob")]
    public string Blob { get; set; } 
}

```

init client:  
private static ElasticClient ElasticClient  
{  
get  
{  
var node = new Uri("[http://localhost:9200](http://localhost:9200)");  
var settings = new ConnectionSettings(node);

```
            settings.DisableDirectStreaming(true);              
            settings.DefaultIndex(_indexName);
            settings.MapDefaultTypeNames(dictionary => dictionary.Add(typeof(Dictionary<string, object>), "docA"));
            return new ElasticClient(settings);
        }
    }

```

byte[] buffer = Encoding.ASCII.GetBytes("text sample");  
string content = Convert.ToBase64String(buffer);  
string json = JsonConvert.SerializeObject(new Attachment  
{  
Name = "FileName" , Blob = content  
});  
var res = ElasticClient.Index(json, descriptor =\> descriptor.Type("docA"));

**Error:**  
**Invalid NEST response built from a unsuccessful low level call on POST: /stackoverflow/docA**  
**# Audit trail of this API call:**  
\*\* - BadResponse: Node: [http://localhost:9200/](http://localhost:9200/) Took: 00:00:00.1160067\*\*  
**# ServerError: ServerError: 400Type: mapper\_parsing\_exception Reason: "failed to parse" CausedBy: "Type: not\_x\_content\_exception Reason: "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes""**  
**# OriginalException: System.Net.WebException: The remote server returned an error: (400) Bad Request.**  
\*\* at System.Net.HttpWebRequest.GetResponse()\*\*  
\*\* at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData)\*\*  
**# Request:**  
**"{"name":"FileName","blob":"dGV4dCBzYW1wbGU="}"**  
**# Response:**  
**{"error":{"root\_cause":[{"type":"mapper\_parsing\_exception","reason":"failed to parse"}],"type":"mapper\_parsing\_exception","reason":"failed to parse","caused\_by":{"type":"not\_x\_content\_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}},"status":400}**

---

<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:21pm UTC](https://discuss.elastic.co/t/index-binary-blob-file-with-nest/60233/2 "2017-07-05T22:21:20Z")

</div>


