# Expected \[SRART\_OBJECT\] but found \[START\_ARRAY\]

**URL:** <https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667>\
**Category:** Elasticsearch\
**Created:** [July 14, 2021, 1:28pm UTC](https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667 "2021-07-14T13:28:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eran1](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@Eran1](https://discuss.elastic.co/u/Eran1)\
**Post date:** [July 14, 2021, 1:28pm UTC](https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667/1 "2021-07-14T13:28:46Z")

</div>

Hi,

I'm using python to connect to elastic as following:

```auto
import urllib3

from elasticsearch import Elasticsearch

from elasticsearch.connection import create_ssl_context

import configparser

 

def get_es_session(es_user, es_password, es_host, es_port):

    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    ssl_context = create_ssl_context()

    ssl_context.check_hostname = False

    ssl_context.verify_mode = False

    es_session = Elasticsearch(

        hosts=[{'host': es_host, 'port': es_port}],

        scheme='https',

        ssl_context=ssl_context,

        http_auth=(es_user, es_password))

    return es_session

```

Then I'm trying to do the simplest search but getting the error above (**Expected [SRART\_OBJECT] but found [START\_ARRAY]**):

```auto
es_session = get_es_session(es_user, es_password, es_host, es_port)

 

        #Init scroll by search

        res = es_session.search(index='digital-dashboard*',

            size=10000,

            from_=0,

            request_timeout=60,

            body=body,

            scroll='5m',

            )

```

The body I'm passing is minimal as it can get:

```auto
{

    "query": {

        "bool": {

            "filter": {

                "range": { "@timestamp": { "gt": "2021-07-12T13:28:54.297000" } }

             }

        }

     }

}

```

I even tried passing it as json and not a dictionary using json.dumps but nothing seems to work.  
Any ideas will be much much appreciated.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 15, 2021, 12:43pm UTC](https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667/2 "2021-07-15T12:43:04Z")

</div>

The body looks good. What wonders me, is your error message of an array starting. As the body you showed does not contain any arrays. Are you sure that this is the body that gets sent?

You can use TRACE logging to show what data gets sent to the server, see [Python Elasticsearch Client — Elasticsearch 7.13.3 documentation](https://elasticsearch-py.readthedocs.io/en/v7.13.3/#logging)

---

<div class="post-metadata">

**Author:** ![Eran1](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@Eran1](https://discuss.elastic.co/u/Eran1)\
**Post date:** [July 15, 2021, 12:47pm UTC](https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667/3 "2021-07-15T12:47:43Z")

</div>

It happens for every body I'm sending.  
I even sent: {"query": {"match\_all": {}}})  
So clearly there is a deeper problem I can't understand.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 16, 2021, 7:59am UTC](https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667/4 "2021-07-16T07:59:36Z")

</div>

As already advised, please use the trace logging above and share the output.

---

<div class="post-metadata">

**Author:** ![Eran1](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@Eran1](https://discuss.elastic.co/u/Eran1)\
**Post date:** [July 18, 2021, 12:23pm UTC](https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667/5 "2021-07-18T12:23:13Z")

</div>

Well I'll try doing that.  
There is hardly a proper example on how to enable the trace so I'll look it up and see.  
Thanks

---

<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:** [August 15, 2021, 12:23pm UTC](https://discuss.elastic.co/t/expected-srart-object-but-found-start-array/278667/6 "2021-08-15T12:23:24Z")

</div>

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