Create query template
POST
/v2/template/create
const url = 'http://localhost:3000/v2/template/create';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"id":"query.template.create","ver":"v2","ts":"2024-04-10T16:10:50+05:30","params":{"msgid":"4a7f14c3-d61e-4d4f-be78-181834eeff6d"},"request":{"query_type":"sql","query":{"queryType":"select","datasetId":"{{DATASET}}","intervals":"{{STARTDATE}}/{{ENDDATE}}","limit":"{{LIMITS}}"}}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:3000/v2/template/create \ --header 'Content-Type: application/json' \ --data '{ "id": "query.template.create", "ver": "v2", "ts": "2024-04-10T16:10:50+05:30", "params": { "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d" }, "request": { "query_type": "sql", "query": { "queryType": "select", "datasetId": "{{DATASET}}", "intervals": "{{STARTDATE}}/{{ENDDATE}}", "limit": "{{LIMITS}}" } } }'Request Body
Section titled “Request Body ” Media type application/json
object
Example
{ "id": "query.template.create", "ver": "v2", "ts": "2024-04-10T16:10:50+05:30", "params": { "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d" }, "request": { "query_type": "sql", "query": { "queryType": "select", "datasetId": "{{DATASET}}", "intervals": "{{STARTDATE}}/{{ENDDATE}}", "limit": "{{LIMITS}}" } }}Responses
Section titled “ Responses ”OK
Media type application/json
object
Examples
Success : Create query template success (json)
{ "id": "api.query.template.create", "ver": "v2", "ts": "2024-04-29T22:29:01+05:30", "params": { "status": "SUCCESS", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "71372ce0-16b9-4594-8db8-f12eff7e6a42" }, "responseCode": "OK", "result": { "template_id": "json11template", "template_name": "json11template", "message": "The query template has been saved successfully" }}Success: Create query template success (SQL)
{ "id": "api.query.template.create", "ver": "v2", "ts": "2024-04-29T22:29:58+05:30", "params": { "status": "SUCCESS", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "62aa8c6d-c49c-41c2-9cc8-2f1b02bc2388" }, "responseCode": "OK", "result": { "template_id": "sql1", "template_name": "sql1", "message": "The query template has been saved successfully" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
359 ETag
string
Example
W/"167-HIMd6+dVF/Wyu6lcmb/+68O4AY4" Date
string
Example
Mon, 29 Apr 2024 16:59:01 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5Bad Request
Media type application/json
object
Examples
Failure: Missing required variables
{ "id": "api.query.template.create", "ver": "v2", "ts": "2024-04-29T22:35:10+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "62e18342-7e25-4122-8fca-6fb12fac3ff0" }, "responseCode": "BAD_REQUEST", "result": {}, "error": { "code": "QUERY_TEMPLATE_INVALID", "message": "Invalid template provided, A template should consist of variables undefined and type of json,sql", "trace": "" }}Failure: Schema validation failure
{ "id": "api.query.template.create", "ver": "v2", "ts": "2024-04-29T22:43:57+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "d2b598b5-62c1-4c5d-b0b3-5d7d109a2bc2" }, "responseCode": "BAD_REQUEST", "result": {}, "error": { "code": "QUERY_TEMPLATE_INVALID_INPUT", "message": "#properties/request/oneOf/0/properties/query_type/enum should be equal to one of the allowed values", "trace": "" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
407 ETag
string
Example
W/"197-y0n7/XzKhcV9HKqgPNj2eo8bzh8" Date
string
Example
Mon, 29 Apr 2024 17:05:10 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5Conflict
Media type application/json
object
Example
{ "id": "api.query.template.create", "ver": "v2", "ts": "2024-04-29T22:33:28+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "18b6b123-4df5-4124-b6ec-73b667250e1c" }, "responseCode": "CONFLICT", "result": {}, "error": { "code": "QUERY_TEMPLATE_ALREADY_EXISTS", "message": "Template josnaks-aaa already exists", "trace": "" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
350 ETag
string
Example
W/"15e-FDXFj2WIyZ1MVllwsiSJoBKU4GQ" Date
string
Example
Mon, 29 Apr 2024 17:03:28 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5