# Problems with escaping input

**URL:** <https://discuss.elastic.co/t/problems-with-escaping-input/8172>\
**Category:** Elasticsearch\
**Created:** [June 20, 2012, 3:41pm UTC](https://discuss.elastic.co/t/problems-with-escaping-input/8172 "2012-06-20T15:41:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Hurlock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jon_hurlock/32/2839_2.png) [@Jon\_Hurlock](https://discuss.elastic.co/u/Jon_Hurlock)\
**Post date:** [June 20, 2012, 3:41pm UTC](https://discuss.elastic.co/t/problems-with-escaping-input/8172/1 "2012-06-20T15:41:28Z")

</div>

Hi All,

I'm having trouble inserting data into Elasticsearch via python, in  
particular the problem concerns handling speech/quotation marks (e.g. "). I  
have tried escaping the speech marks however, it seems to have no effect,  
the following error appears:

jonhurlock@cspcjh  
~/h/hadoop-0.20.203.0/playground/py/snap/indexing/elastic: python  
curltest.py

- About to connect() to localhost port 9200 (#0)
- Trying ::1... \* connected
- Connected to localhost (::1) port 9200 (#0)

> POST /twitter/tweet/22499999 HTTP/1.1  
> User-Agent: PycURL/7.19.5  
> Host: localhost:9200  
> Accept: _/_  
> Content-Length: 174  
> Content-Type: application/x-www-form-urlencoded

\< HTTP/1.1 400 Bad Request  
\< Content-Type: application/json; charset=UTF-8  
\< Content-Length: 229  
\<

- Connection #0 to host localhost left intact
- Closing connection #0  
{"error":"MapperParsingException[Failed to parse]; nested:  
JsonParseException[Unexpected character ('l' (code 108)): was expecting  
comma to separate OBJECT entries\n at [Source: [B@626bb7a7; line: 1, column: 81]]; ","status":400}

I have given some examples in the following gist.

> <https://gist.github.com/jonhurlock/2960359>

Any help would be much appreciated.

Jon Hurlock

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 21, 2012, 7:25am UTC](https://discuss.elastic.co/t/problems-with-escaping-input/8172/2 "2012-06-21T07:25:14Z")

</div>

The json is simply invalid, why not use a python json lib to build the json?

On Wed, Jun 20, 2012 at 5:41 PM, Jon Hurlock [jonhurlock@gmail.com](mailto:jonhurlock@gmail.com) wrote:

> Hi All,
> 
> I'm having trouble inserting data into Elasticsearch via python, in  
> particular the problem concerns handling speech/quotation marks (e.g. "). I  
> have tried escaping the speech marks however, it seems to have no effect,  
> the following error appears:
> 
> jonhurlock@cspcjh~/h/hadoop-0.20.203.0/playground/py/snap/indexing/elastic: python  
> curltest.py
> 
> - About to connect() to localhost port 9200 (#0)
> - Trying ::1... \* connected
> - Connected to localhost (::1) port 9200 (#0)
> 
> > POST /twitter/tweet/22499999 HTTP/1.1  
> > User-Agent: PycURL/7.19.5  
> > Host: localhost:9200  
> > Accept: _/_  
> > Content-Length: 174  
> > Content-Type: application/x-www-form-urlencoded
> 
> \< HTTP/1.1 400 Bad Request  
> \< Content-Type: application/json; charset=UTF-8  
> \< Content-Length: 229  
> \<
> 
> - Connection #0 to host localhost left intact
> - Closing connection #0  
> {"error":"MapperParsingException[Failed to parse]; nested:  
> JsonParseException[Unexpected character ('l' (code 108)): was expecting  
> comma to separate OBJECT entries\n at [Source: [B@626bb7a7; line: 1, column: 81]]; ","status":400}
> 
> I have given some examples in the following gist.
> 
> [Example Python Code showing cURLing data and POSTing data to Elastic Search, but fails with escaped speech marks · GitHub](https://gist.github.com/2960359)
> 
> Any help would be much appreciated.
> 
> Jon Hurlock

---

<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 6, 2017, 3:23am UTC](https://discuss.elastic.co/t/problems-with-escaping-input/8172/3 "2017-07-06T03:23:12Z")

</div>


