# How do I save array of bytes as actual array in NEST

**URL:** <https://discuss.elastic.co/t/how-do-i-save-array-of-bytes-as-actual-array-in-nest/148747>\
**Category:** Elasticsearch\
**Created:** [September 16, 2018, 8:50pm UTC](https://discuss.elastic.co/t/how-do-i-save-array-of-bytes-as-actual-array-in-nest/148747 "2018-09-16T20:50:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pzixel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pzixel/32/29568_2.png) [@Pzixel](https://discuss.elastic.co/u/Pzixel)\
**Post date:** [September 16, 2018, 8:50pm UTC](https://discuss.elastic.co/t/how-do-i-save-array-of-bytes-as-actual-array-in-nest/148747/1 "2018-09-16T20:50:25Z")

</div>

I have a simple POCO object with following definition

```
public class MyClass 
{
   public byte[] Assortment {get;set;}
}

```

And I want to save it as `[1,2,3]` in elasticsearch. But when I simply create an object of that type and insert it into index I just get binary encoded value like `AQMoAgkEBwUILy0uJicG`. Sample code:

```
var settings = new ConnectionSettings(new Uri(elasticSettings.NodeUri)).DefaultIndex(elasticSettings.Index);
var elasticClient = new ElasticClient(settings);
MyClass[] requests = { new MyClass {Assortment = new byte[] {1,3,40,2,9,4,7,5,8,47,45,46,38,39,6} }};
var bulkResponse = await elasticClient.IndexManyAsync(requests, cancellationToken: cancellationToken);

```

If I manually create an index and set array type I get following errors when saving:

```
System.AggregateException: One or more errors occurred. (Error while processing bulk request: Invalid NEST response built from a successful low level call on POST: /_bulk
# Invalid Bulk items:
  operation[0]: index returned 400 _index: blockchain _type: elasticrequest _id: eqa04WUByNd1edqilegT _version: 0 error: Type: mapper_parsing_exception Reason: "failed to parse [assortment]" CausedBy:
Type: illegal_argument_exception Reason: "For input string: "AQMoAgkEBwUILy0uJicG""
  operation[1]: index returned 400 _index: blockchain _type: elasticrequest _id: e6a04WUByNd1edqilegT _version: 0 error: Type: mapper_parsing_exception Reason: "failed to parse [assortment]" CausedBy:
Type: illegal_argument_exception Reason: "For input string: "AQMoAgkEBwUILy0uJicG""
  operation[2]: index returned 400 _index: blockchain _type: elasticrequest _id: fKa04WUByNd1edqilegT _version: 0 error: Type: mapper_parsing_exception Reason: "failed to parse [assortment]" CausedBy:
Type: illegal_argument_exception Reason: "For input string: "AQMoAgkEBwUILy0uJicG""

```

I don't want to binary encode the value, I just want to create an array of values.

I tried Text/Number/Object attributes, but they don't work.

---

<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:** [October 14, 2018, 8:50pm UTC](https://discuss.elastic.co/t/how-do-i-save-array-of-bytes-as-actual-array-in-nest/148747/2 "2018-10-14T20:50:30Z")

</div>

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