# Json\_parse\_exception multisearch

**URL:** <https://discuss.elastic.co/t/json-parse-exception-multisearch/278116>\
**Category:** Elasticsearch\
**Created:** [July 7, 2021, 9:43pm UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116 "2021-07-07T21:43:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![draft10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/draft10/32/91309_2.png) [@draft10](https://discuss.elastic.co/u/draft10)\
**Post date:** [July 7, 2021, 9:43pm UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116/1 "2021-07-07T21:43:54Z")

</div>

curl -X GET --user user:pass "localhost:port/element1-2021.07.06/\_msearch?pretty" -H 'Content-Type: application/json' -d'  
{ }  
{"query": {"match" : {"application":"Scanner"}}}  
{"index": "element1-2021.07.06"}  
{"query" : {"match":{"processed.Severity":"ERROR"}}}  
'  
When I run the query above I'm getting:  
{  
"type" : "json\_parse\_exception",  
"reason" : "Unexpected character ('\' (code 92)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"  
}  
Could anyone give me a hand please?

---

<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 8, 2021, 11:08am UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116/2 "2021-07-08T11:08:37Z")

</div>

wild guess: You should not start with an empty line, as the first line should contain the metadata of your first document.

---

<div class="post-metadata">

**Author:** ![draft10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/draft10/32/91309_2.png) [@draft10](https://discuss.elastic.co/u/draft10)\
**Post date:** [July 8, 2021, 4:51pm UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116/3 "2021-07-08T16:51:10Z")

</div>

I have done it as well I get the same result, Alexander please give a hand mate there is no much information on \_msearch thanks a lot.  
$ curl -X GET --user user:pass "localhost:port/element1-2021.07.06/\_msearch?pretty" -H "Content-Type: application/json" -d'  
{"query": {"match" : {"application":"Scanner"}}}  
{"index": "element1-2021.07.06"}  
{"query" : {"match":{"processed.Severity":"ERROR"}}}  
'  
% Total % Received % Xferd Average Speed Time Time Time Current  
Dload Upload Total Spent Left Speed  
100 816 100 656 100 160 1898 463 --:--:-- --:--:-- --:--:-- 2365{  
"error" : {  
"root\_cause" : [  
{  
"type" : "json\_parse\_exception",  
"reason" : "Unexpected character ('\' (code 92)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"  
}  
],  
"type" : "json\_parse\_exception",  
"reason" : "Unexpected character ('\' (code 92)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 2]"  
},  
"status" : 400  
}

---

<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 9, 2021, 8:07am UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116/4 "2021-07-09T08:07:31Z")

</div>

the way your example is formatted, your first line is an empty line and does not have any content. If that is not the case please provide a more exact reproduction.

You can use the `--trace-ascii` parameter in curl to write a log how your data is sent. This will allow you to verify what data your are sending.

---

<div class="post-metadata">

**Author:** ![draft10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/draft10/32/91309_2.png) [@draft10](https://discuss.elastic.co/u/draft10)\
**Post date:** [July 9, 2021, 1:16pm UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116/5 "2021-07-09T13:16:39Z")

</div>

It is set in the same exact way your documentation mentions it: 🙂

[Multi search API | Elasticsearch Guide [7.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html)  
curl -X GET "localhost:9200/my-index-000001/\_msearch?pretty" -H 'Content-Type: application/json' -d'  
{ }  
{"query" : {"match" : { "message": "this is a test"}}}  
{"index": "my-index-000002"}  
{"query" : {"match\_all" : {}}}  
'

---

<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 12, 2021, 8:08am UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116/6 "2021-07-12T08:08:06Z")

</div>

Just to be sure, we get this properly reproduced:

- You went to the first example, clicked on `copy as curl`
- Pasted this in your terminal
- Received the above error?

I just did the same and it worked for me, so I suppose there must be a slight difference in what we did.

---

<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 9, 2021, 8:08am UTC](https://discuss.elastic.co/t/json-parse-exception-multisearch/278116/7 "2021-08-09T08:08:33Z")

</div>

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