# Only in AWS Lambda: Json\_parse\_exception Illegal character CTRL-CHAR code 31

**URL:** <https://discuss.elastic.co/t/only-in-aws-lambda-json-parse-exception-illegal-character-ctrl-char-code-31/228585>\
**Category:** Elasticsearch\
**Created:** [April 17, 2020, 9:25pm UTC](https://discuss.elastic.co/t/only-in-aws-lambda-json-parse-exception-illegal-character-ctrl-char-code-31/228585 "2020-04-17T21:25:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![derrickl](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@derrickl](https://discuss.elastic.co/u/derrickl)\
**Post date:** [April 17, 2020, 9:25pm UTC](https://discuss.elastic.co/t/only-in-aws-lambda-json-parse-exception-illegal-character-ctrl-char-code-31/228585/1 "2020-04-17T21:25:39Z")

</div>

Hi all,

I'm using the python Elasticsearch library to query an index. When I run the search on AWS Lambda I get this json\_parse\_execption:

```auto
"errorMessage": "TransportError(500, 'json_parse_exception', 'Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\\\r, \\\\n, \\\\t) is allowed between tokens\\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@2841b17e; line: 1, column: 2]')",
"errorType": "TransportError"

```

However, when I run the code locally, the same body argument works perfectly. Additionally, I can use this syntax in Kibana and get correct results.

```auto
        posts = {
            "aggs": {
                "id": {
                    "terms": {
                        "field": "content.id"
                    },
                    "aggregations": {
                        "eng_avg": {
                            "avg": {
                                "field": "content.engagement"
                            }
                        },
                        "fol_avg": {
                            "avg": {
                                "field": "content.followers"
                            }
                        }
                    }
                }
            },
            "query": {
                "range": {
                    "content.timestamp": {
                        "gte": "now-90d"
                    }
                }
            }, "size": 0
        }

```

`es_results = es_client.search(index="social_posts", body=posts)`

I've been staring at this Json body for a while and can't see any issues with it... maybe I missed something?

When I test the code in AWS Lambda without any `body=<json>` results are returned... so the ES client seems to be talking to the Custer.

Any thoughts would be lovely. Thank you!

---

<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:** [May 15, 2020, 9:36pm UTC](https://discuss.elastic.co/t/only-in-aws-lambda-json-parse-exception-illegal-character-ctrl-char-code-31/228585/2 "2020-05-15T21:36:09Z")

</div>

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