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");
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/ 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}