Via the REST API, you can work with user queries in the usual way, just like with any other record type — at the address /c/{firma}/uzivatelsky-dotaz. In addition, you can also call a saved query and get its result.
Calling a query
The simplest query — one that has no parameters, or where all parameters have sufficient default values — is called as follows:
GET https://demo.flexibee.eu/c/demo/uzivatelsky-dotaz/1/call.xml
The number 1 corresponds to the ID of the given user query; instead of the ID, you can also use its code in the form code:ZKRATKA. You specify the output format using the extension .xml or .json, and the usual parameters for detail level and pagination also work.
The query result is returned in the DotazView element, whose properties correspond to the columns defined in the query:
{
"winstrom": {
"@version": "1.0",
"DotazView": [
{
"nazev": "ABRA Flexi s.r.o.",
"sloupec": "dic",
"puvodni_hodnota": "CZ28019920",
"zmenena_na": "",
"uzivatelem": "admin",
"datcas": "2021.09.09 - 13:59:50"
}
]
}
}
Query parameters
If a query has parameters, specify a parameter in the URL for each one. For example, if the query has a parameter datum, the call looks like this:
GET .../uzivatelsky-dotaz/1/call.xml?datum=2012-01-01
If a query parameter has a cardinality of N, meaning multiple values can be specified, simply repeat the parameter in the URL — for example, to select several companies:
GET .../uzivatelsky-dotaz/1/call.xml?firma=code:FIRMA1&firma=code:FIRMA2
In the saved query, then use the IN (<<firma>>) operator.
ℹ️ Parameter values are written in the usual way and are not enclosed in quotation marks. Don't forget to encode them correctly in the URL.
Passing parameters using the POST method
In addition to GET, a query can also be called using the POST method, which allows a large number of parameters to be passed in the request body. Parameters can be passed in three ways.
In a JSON structure
POST .../uzivatelsky-dotaz/code:TEST_JSON_PARAMS/call.json
Content-Type: application/json
{
"param1": "hodnota1",
"param2": "hodnota2",
"param3": 123
}
In an XML structure
POST .../uzivatelsky-dotaz/code:TEST_XML_PARAMS/call.xml
Content-Type: application/xml
<?xml version="1.0" encoding="UTF-8"?>
<winstrom>
<param1>hodnota1</param1>
<param2>hodnota2</param2>
<param3>123</param3>
</winstrom>
As form data
Parameters can also be sent as application/x-www-form-urlencoded. In this case, the URL must not contain a format extension — specify the output format using the Accept header instead:
POST .../uzivatelsky-dotaz/code:TEST_PARAMS/call
Content-Type: application/x-www-form-urlencoded
Accept: application/json
param1=hodnota1¶m2=hodnota2¶m3=888
⚠️ If you send form data to an address with an extension, the server will try to parse the body as JSON or XML, and the response will be 400 — Failed to parse JSON body, or Failed to parse XML body, respectively.
Printing a saved query
Saved queries can also be printed. A custom print template must be created for each saved query and selected for that query; the print can then also be called via the REST API — the procedure is described in the article Exporting print reports.
