# Curl with elasticsearch

**URL:** <https://discuss.elastic.co/t/curl-with-elasticsearch/102961>\
**Category:** Elasticsearch\
**Created:** [October 6, 2017, 7:32am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961 "2017-10-06T07:32:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [October 6, 2017, 7:32am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/1 "2017-10-06T07:32:27Z")

</div>

Hi everyone,  
My pc is windows 10. I want to use curl command to get the data from elasticsearch, but I have some problems.  
this is my curl command (a small test):  
curl -GET "[http://localhost:9200/\_search](http://localhost:9200/_search)" -d'{"query": {"match\_all": {}}}'

and the cmd show the error:  
{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"request [  
/\_search] contains unrecognized parameter: ['{query:]"}],"type":"illegal\_argumen  
t\_exception","reason":"request [/\_search] contains unrecognized parameter: ['{qu  
ery:]"},"status":400}curl: (3) [globbing] unmatched brace in column 1  
curl: (3) [globbing] empty string within braces in column 2

could anyone help me?

thank you in advance.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 6, 2017, 7:50am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/2 "2017-10-06T07:50:02Z")

</div>

curl on windows is often a pain.

I'd recommend using Kibana Dev Console instead.

May be you are missing space?

```
curl "http://localhost:9200/_search" -d '{"query": {"match_all": {}}}'

```

BTW this is the same as:

```
curl "http://localhost:9200/_search"
```

---

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [October 6, 2017, 7:58am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/3 "2017-10-06T07:58:20Z")

</div>

thanks for your reply.  
I try to add the space:  
`curl "http://localhost:9200/_search" -d '{"query": {"match_all": {}}}'`

and the error became to this one:  
{"error":"Content-Type header [application/x-www-form-urlencoded] is not support  
ed","status":406}curl: (3) [globbing] unmatched brace in column 1  
curl: (3) [globbing] empty string within braces in column 2

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 6, 2017, 8:14am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/4 "2017-10-06T08:14:18Z")

</div>

You need to add `-H 'Content-Type: application/json'`

---

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [October 6, 2017, 8:19am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/5 "2017-10-06T08:19:42Z")

</div>

the same error \>\<  
{"error":"Content-Type header [application/x-www-form-urlencoded] is not support  
ed","status":406}curl: (3) [globbing] unmatched brace in column 1  
curl: (3) [globbing] empty string within braces in column 2

this is my command:  
`curl "http://localhost:9200/_search" -d '{"query": {"match_all": {}}}' -H 'Content-Type: application/json'`

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 6, 2017, 8:23am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/6 "2017-10-06T08:23:16Z")

</div>

It means that `-H 'Content-Type: application/json'` did not work. Look at the curl documentation for windows. May be another option.

Again, you will save your time by starting a Kibana instance.

---

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [October 6, 2017, 8:33am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/7 "2017-10-06T08:33:05Z")

</div>

ok, thank you!  
the query in kibana is great to work.  
and I need to get the data from curl tool. so I am trying.

---

<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:** [November 3, 2017, 8:33am UTC](https://discuss.elastic.co/t/curl-with-elasticsearch/102961/8 "2017-11-03T08:33:10Z")

</div>

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