# Http get request using libcurl in json format

**URL:** <https://discuss.elastic.co/t/http-get-request-using-libcurl-in-json-format/9564>\
**Category:** Elasticsearch\
**Created:** [November 5, 2012, 5:28pm UTC](https://discuss.elastic.co/t/http-get-request-using-libcurl-in-json-format/9564 "2012-11-05T17:28:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dinesh\_Sriram](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@Dinesh\_Sriram](https://discuss.elastic.co/u/Dinesh_Sriram)\
**Post date:** [November 5, 2012, 5:28pm UTC](https://discuss.elastic.co/t/http-get-request-using-libcurl-in-json-format/9564/1 "2012-11-05T17:28:57Z")

</div>

Hi All,  
I am using libcurl to add indices and retrieve search results. I would like  
to know whether there is a way to send http get requests using libcurl in  
json format?  
For example, the request in curl is

curl -XGET [http://localhost:9200/\_all/tweet/\_search?q=tag:warcraft](http://localhost:9200/_all/tweet/_search?q=tag:warcraft)

Its equivalent in libcurl is

curl\_easy\_setopt(curl\_handle, CURLOPT\_URL,  
"[http://localhost:9200/\_search?q=tag:warcraft](http://localhost:9200/_search?q=tag:warcraft)")

I would like to send the above request in json format (below).

curl -XGET [http://localhost:9200/\_search](http://localhost:9200/_search) -d '{ "query" : { "term" : { "tag": "warcraft" } } }'

Is there a way to do this?

--

---

<div class="post-metadata">

**Author:** ![Dinesh\_Sriram](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@Dinesh\_Sriram](https://discuss.elastic.co/u/Dinesh_Sriram)\
**Post date:** [November 6, 2012, 6:51pm UTC](https://discuss.elastic.co/t/http-get-request-using-libcurl-in-json-format/9564/2 "2012-11-06T18:51:04Z")

</div>

[c - libcurl http get request in json format - Stack Overflow](http://stackoverflow.com/questions/13236479/libcurl-http-get-request-in-json-format) in  
case if anyone's interested.

On Monday, November 5, 2012 12:28:57 PM UTC-5, Dinesh Sriram wrote:

> Hi All,  
> I am using libcurl to add indices and retrieve search results. I would  
> like to know whether there is a way to send http get requests using libcurl  
> in json format?  
> For example, the request in curl is
> 
> curl -XGET [http://localhost:9200/\_all/tweet/\_search?q=tag:warcraft](http://localhost:9200/_all/tweet/_search?q=tag:warcraft)
> 
> Its equivalent in libcurl is
> 
> curl\_easy\_setopt(curl\_handle, CURLOPT\_URL, "  
> [http://localhost:9200/\_search?q=tag:warcraft](http://localhost:9200/_search?q=tag:warcraft)")
> 
> I would like to send the above request in json format (below).
> 
> curl -XGET [http://localhost:9200/\_search](http://localhost:9200/_search) -d '{ "query" : { "term" : { "tag": "warcraft" } } }'
> 
> Is there a way to do this?

--

---

<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:05am UTC](https://discuss.elastic.co/t/http-get-request-using-libcurl-in-json-format/9564/3 "2017-07-06T03:05:54Z")

</div>


