Connecting to the Qlik Sense ODAG service API
The ODAG service API has a set of endpoints that allow you to generate apps on-demand.
Connections to the ODAG Service API endpoints are made using HTTPS by default. When communicating with the ODAG Service API, the URLs all have the following form:
https://hostname/api/odag/v1/<endpoint>
where <endpoint> is one of the ODAG Service API endpoints.
Here are some examples of ODAG service API endpoints.
-
POST {url}/api/odag/v1/links (Creates a new link that enables ODAG navigation from a designated selection app to a template app.)
-
GET {url}/api/odag/v1/links (Gets navigation links and their properties.)
For a complete list of endpoints, refer to Qlik Sense ODAG service API reference.
Examples
The following examples are based on the sample app called OnDemandApp, which is packaged with every Qlik Sense installation. These examples take you through the sequence of creating a navigation link, creating an app generation request, and checking the status of the request. Postman is used to make the API requests.
Before you send a request, you need to have a selection app and template app and know their IDs.
- Start Postman.
- Set the HTTP method to POST.
- Enter the following path in the URL area:
{url}/api/odag/v1/links
The full URL should look something like: https://example.com/api/odag/v1/links.
- Select Headers and add Content-Type as the key with application/json as the value.
- In the body of the request, set the attributes of the link. For example:
{ "name": "ODAGLink", "selectionApp": "6c310899-2cef-4937-9c48-3c4e10c9859b", "templateApp": "173e03a3-246d-49c6-b16e-325d271e8ab6", "rowEstExpr": "SUM(FLIGHT_COUNT)", "properties": { "rowEstRange": [ { "context": "*", "highBound": 100000 }] } }
- Click Send.
The JSON response from the API should look something like this:
{
"objectDef": {
"id": "c5c569f5-eb21-4c42-83a3-8f245d213b36",
"createdDate": "2019-07-04T19:30:27.746Z",
"modifiedDate": "2019-07-04T19:30:27.746Z",
"modifiedByUserName": "INTERNAL\\sa_api",
"owner": {
"id": "37a73022-6fe3-44f9-af79-ff538222c33b",
"userId": "",
"userDirectory": "INTERNAL",
"name": "sa_api",
"privileges": null
},
"name": "ODAGLink",
"templateApp": {
"id": "173e03a3-246d-49c6-b16e-325d271e8ab6",
"name": "",
"appId": "",
"publishTime": "1753-01-01T00:00:00.000Z",
"published": false,
"stream": null,
"savedInProductVersion": "",
"migrationHash": "",
"availabilityStatus": 0,
"privileges": null
},
"templateAppOrigName": "ODAG Sample Detail",
"loadScriptHash": 3601132354136866,
"rowEstExpr": "SUM(FLIGHT_COUNT)",
"bindings": [
{
"templateAppVarName": "Origin Code",
"selectAppParamType": "Field",
"selectAppParamName": "Origin Code",
"selectionStates": "SO",
"numericOnly": false
},
{
"templateAppVarName": "Destination Code",
"selectAppParamType": "Field",
"selectAppParamName": "Destination Code",
"selectionStates": "SO",
"numericOnly": false
},
{
"templateAppVarName": "Year",
"selectAppParamType": "Field",
"selectAppParamName": "Year",
"selectionStates": "SO",
"numericOnly": false
},
{
"templateAppVarName": "Quarter",
"selectAppParamType": "Field",
"selectAppParamName": "Quarter",
"selectionStates": "SO",
"numericOnly": false
},
{
"templateAppVarName": "Ticket Carrier Code",
"selectAppParamType": "Field",
"selectAppParamName": "Ticket Carrier Code",
"selectionStates": "SO",
"numericOnly": false
},
{
"templateAppVarName": "Fare Class",
"selectAppParamType": "Field",
"selectAppParamName": "Fare Class",
"selectionStates": "SO",
"numericOnly": false
}],
"properties": {
"rowEstRange": [
{
"context": "*",
"highBound": 100000
}
],
"menuLabel": [
{
"context": "*",
"label": "ODAGLink"
}],
"genAppName": [
{
"userContext": "*",
"formatString": "{0}_{1}-{2}",
"params": [
"templateAppName",
"userDirectory",
"userId"
]
}]
},
"modelGroups": [],
"privileges": [
"create",
"read",
"update",
"delete",
"changeowner"
],
"status": "active"
},
"feedback": []
}
This example builds on the previous example where we created navigation links between a selection app and template app. Before you send the request, you need to have a navigation link and know its ID.
- Start Postman.
- Set the HTTP method to POST.
- Enter the following path in the URL area:
{url}/api/odag/v1/links/{linkId}/requests
The full URL should look something like https://example.com/api/odag/v1/links/c5c569f5-eb21-4c42-83a3-8f245d213b36/requests.
- Select Headers and add Content-Type as the key with application/json as the value.
- In the body of the request, set up the request payload. For example:
{ "selectionApp": "6c310899-2cef-4937-9c48-3c4e10c9859b", "sheetname": "RWcstb", "clientContextHandle": "GnUxtA", "actualRowEst": 187, "bindSelectionState": [ { "selectionAppParamType": "Field", "selectionAppParamName": "Origin Code", "values": [ { "selStatus": "S", "strValue":"ORD", "numValue":"NaN" } ] } ] }
- Click Send.
The JSON response from the API should look something like this:
{
"id": "76dee244-8717-455d-bd31-a5baeefd525f",
"createdDate": "2019-07-10T17:55:09.916Z",
"modifiedDate": "2019-07-10T17:55:09.916Z",
"modifiedByUserName": "sa_api",
"owner":
{
"id": "e19dca4f-2291-45af-97d7-d4e3ceb09f64",
"userId": "",
"userDirectory": "INTERNAL",
"name": "sa_api",
"privileges": null
},
"createdByAnonymousUser": "",
"link":
{
"id": "c5c569f5-eb21-4c42-83a3-8f245d213b36",
"owner": null,
"name": "",
"templateApp": null,
"templateAppOrigName": "",
"rowEstExpr": "",
"privileges": null,
"status": "active"
},
"selectionAppId": "6c310899-2cef-4937-9c48-3c4e10c9859b",
"selectionAppOrigName": "ODAG Sample Selection",
"sheetname": "RWcstb",
"clientContextHandle": "GnUxtA",
"targetSheet": "",
"generatedAppOrigName": "ODAG Sample Detail_sa_api",
"generatedApp": null,
"engineGroup": null,
"parentRequestId": "",
"engine": "",
"timeToLive": 2880,
"purgeAfter": "",
"curRowEstExpr": "SUM(FLIGHT_COUNT)",
"curRowEstLowBound": 0,
"curRowEstHighBound": 100000,
"actualRowEst": 187,
"bindingStateHash": 565665802437790,
"selectionState": "",
"selectionStateHash": 0,
"privileges": [
"create",
"read",
"update",
"delete"
],
"kind": "single",
"state": "queued",
"reloadCount": 0,
"loadState":
{
"status": "pending"
},
"retentionTime": 0,
"bindSelectionState": [
{
"selectionAppParamType": "Field",
"selectionAppParamName": "Origin Code",
"values": [
{
"selStatus": "S",
"strValue": "ORD",
"numValue": "NaN"
}
]
}
]
}
Before you send a request, you need to know the ID of the app generation request.
- Start Postman.
- Set the HTTP method to GET.
- Enter the following path in the URL area:
{url}/api/odag/v1/requests/{requestId}
The full URL should look something like https://example.com/api/odag/v1/requests/a05569f5-f321-9h42-83a3-8f245d213d21.
- Select Headers and add Content-Type as the key with application/json as the value.
- Click Send.
The JSON response from the API should look something like this:
{
"id": "76dee244-8717-455d-bd31-a5baeefd525f",
"createdDate": "2019-07-10T17:55:09.916Z",
"modifiedDate": "2019-07-10T17:55:12.999Z",
"modifiedByUserName": "INTERNAL\\sa_api",
"owner":
{
"id": "e19dca4f-2291-45af-97d7-d4e3ceb09f64",
"userId": "sa_api",
"userDirectory": "INTERNAL",
"name": "sa_api",
"privileges": null
},
"createdByAnonymousUser": "",
"link":
{
"id": "c5c569f5-eb21-4c42-83a3-8f245d213b36",
"owner":
{
"name": "TestLink1",
"templateApp":
{
"id": "173e03a3-246d-49c6-b16e-325d271e8ab6",
"name": "ODAG Sample Detail",
"appId": "",
...
},
"templateAppOrigName": "ODAG Sample Detail",
"rowEstExpr": "SUM(FLIGHT_COUNT)",
"privileges": null,
"status": "active"
},
"selectionAppId": "6c310899-2cef-4937-9c48-3c4e10c9859b",
"selectionAppOrigName": "ODAG Sample Selection",
...
"stream":
{
"id": "aaec8d41-5201-43ab-809f-3063750dfafd",
"name": "Everyone",
"privileges": null
},
"savedInProductVersion": "12.390.0",
"migrationHash": "",
"availabilityStatus": 0,
"privileges": null
},
"engineGroup": null,
"parentRequestId": "",
"timeToLive": 2880,
...
"privileges": [
"create",
"read",
"update",
"delete"
],
"loadState":
{
"messages":
{
...
}
"status": "success",
"loadHost": "server.example.com",
"startedAt": "2019-07-10T17:55:11.182Z",
"finishedAt": "2019-07-10T17:55:12.444Z"
},
"kind": "single",
"state": "succeeded",
"reloadCount": 1,
"retentionTime": 0,
"bindSelectionState": [
{
"selectionAppParamType": "Field",
"selectionAppParamName": "Origin Code",
"values": [
{
"selStatus": "S",
"strValue": "ORD",
"numValue": "NaN"
}
]
}
],
"publishToStreamName": "Everyone"
}