Send T-SQL queries over RESTful web API
This article describes how to use a subset of the T-SQL language to send T-SQL queries via the REST API. This article describes how to use a subset of the T-SQL language to send T-SQL queries via the REST API.
Request structure
To send T-SQL queries to the API, create a POST request with the following components.
To copy your URI, in the Azure portal, go to your cluster’s overview page, and then select the URI. Replace <your_cluster> with your Azure Data Explorer cluster name.
To copy your URI, see Copy a KQL database URI. To copy your URI, see Copy a KQL database URI.
```makefile
Accept:application/json
Content-Type:application/json; charset=utf-8
```
Body: Set the
cslproperty to the text of your T-SQL query, and the client request propertyquery_languagetosql.Body: Set the
cslproperty to the text of your T-SQL query, and the client request propertyquery_languagetosql.{ "properties": { "Options": { "query_language": "sql" } } }
Example
The following example shows a request body with a T-SQL query in the csl field and the query_language client request property set to sql.
{
"db": "MyDatabase",
"csl": "SELECT top(10) * FROM MyTable",
"properties": {
"Options": {
"query_language": "sql"
}
}
}
The response is in a format similar to the following.
{
"Tables": [
{
"TableName": "Table_0",
"Columns": [
{
"ColumnName": "rf_id",
"DataType": "String",
"ColumnType": "string"
},
...
],
"Rows": [
[
"b9b84d3451b4d3183d0640df455399a9",
...
],
...
]
}
]
}
Related content
- Learn more about T-SQL limitations
- Learn more about T-SQL limitations
- See the REST API overview
- See the REST API overview
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.