# Accessing SQL API from http(s)

**URL:** https://discuss.elastic.co/t/accessing-sql-api-from-http-s/205047
**Category:** Elasticsearch
**Tags:** elastic-stack-sql
**Created:** [October 24, 2019, 11:31am UTC](https://discuss.elastic.co/t/accessing-sql-api-from-http-s/205047 "2019-10-24T11:31:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![madhusoodanan](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@madhusoodanan](https://discuss.elastic.co/u/madhusoodanan)
#### Post date: [October 24, 2019, 11:31am UTC](https://discuss.elastic.co/t/accessing-sql-api-from-http-s/205047/1 "2019-10-24T11:31:03Z")

</div>

wonder if there are any way to call ES SQL API, say like  
[http://localhost:9200/\_sql?format=json&source=](http://localhost:9200/_sql?format=json&source=){“query”: “SELECT 1” }  
similer to  
[http://localhost:9200//hockey/\_search?q=johnny](http://localhost:9200//hockey/_search?q=johnny)

# This gives error. "source and source\_content\_type parameters are required"

NB:

# the following curl script works fine.

curl -X GET "localhost:9200/\_sql" -H 'Content-Type: application/json' -d'SELECT 1'

# minimal script to create the index

PUT hockey/\_bulk?refresh  
{"index":{"\_id":1}}  
{"first":"johnny","last":"gaudreau","goals":[9,27,1],"assists":[17,46,0],"gp":[26,82,1],"born":"1993/08/13"}

---

<div class="post-metadata">

### Author: ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)
#### Post date: [October 25, 2019, 7:30am UTC](https://discuss.elastic.co/t/accessing-sql-api-from-http-s/205047/2 "2019-10-25T07:30:38Z")

</div>

@madhusoodanan yes, this is possible:

```auto
http://localhost:9200/_sql?source={"query":"SELECT 1"}&source_content_type=application/json&format=txt

```

---

<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 22, 2019, 7:30am UTC](https://discuss.elastic.co/t/accessing-sql-api-from-http-s/205047/3 "2019-11-22T07:30:55Z")

</div>

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