Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
sri_c003
Partner - Creator II
Partner - Creator II

QRS API: export and import tasks

We are trying to export and import tasks from one instance to another (similar instances). Or there could be cases where a user might want to export and import tasks. I do not see this support on the UI, and so are looking for ways to do this via QRS API. Any guidance on the approach here would be much appreciated.

1 Solution

Accepted Solutions
Levi_Turner
Employee
Employee

In all honesty, this would be a ship of theseus situation. Let's take an example reload task.

Get the reload task details (GET /qrs/reloadtask/{id}):

{
  "id": "3f053d35-e1e6-40f0-b3de-449c009ce99d",
  "createdDate": "2019-06-25T19:25:59.44Z",
  "modifiedDate": "2021-07-09T13:18:25.801Z",
  "modifiedByUserName": "<domain>\<userId>",
  "customProperties": [],
  "app": {
    "id": "53c667f8-b6b9-431e-991e-fd9f9bf5d38f",
    "name": "Operations Monitor",
    "appId": "",
    "publishTime": "2021-05-11T15:00:10.754Z",
    "published": true,
    "stream": {
      "id": "a70ca8a5-1d59-4cc9-b5fa-6e207978dcaf",
      "name": "Monitoring apps",
      "privileges": null
    },
    "savedInProductVersion": "12.969.2",
    "migrationHash": "21ecc792c56e18162f1785d3d41f28fdaced5c96",
    "availabilityStatus": 0,
    "privileges": null
  },
  "isManuallyTriggered": false,
  "operational": {
    "id": "8843c59f-d721-4379-a8e5-c5c38a3292ca",
    "lastExecutionResult": {
      "id": "cffa8426-e333-4138-b8cd-1f17228a6cfb",
      "executingNodeName": "<server.domain.ad>",
      "status": 7,
      "startTime": "2021-10-19T14:30:59.512Z",
      "stopTime": "2021-10-19T14:34:16.995Z",
      "duration": 197483,
      "fileReferenceID": "e0f7dcfc-2542-4873-8ff3-0471621e7491",
      "scriptLogAvailable": false,
      "details": [
        {
          "id": "6fe61b23-a114-4ce7-8303-977dab098334",
          "detailsType": 2,
          "message": "Changing task state from Triggered to Started",
          "detailCreatedDate": "2021-10-19T14:30:59.73Z",
          "privileges": null
        },
        {
          "id": "52f73b1c-f88a-4725-9dd3-d8eb79bb1eda",
          "detailsType": 2,
          "message": "Changing task state to Triggered",
          "detailCreatedDate": "2021-10-19T14:30:59.512Z",
          "privileges": null
        },
        {
          "id": "c457b3c5-e4cb-42c7-ace3-e628160e3749",
          "detailsType": 2,
          "message": "Trying to start task. Sending task to slave scheduler usral-ltu2.qliktech.com",
          "detailCreatedDate": "2021-10-19T14:30:59.625Z",
          "privileges": null
        },
        {
          "id": "69ccb2a5-df02-4ad6-943d-d6163a5a0719",
          "detailsType": 2,
          "message": "Reference to scriptlog added",
          "detailCreatedDate": "2021-10-19T14:34:16.96Z",
          "privileges": null
        },
        {
          "id": "6361b448-4dd1-485d-b378-466e53561e6e",
          "detailsType": 2,
          "message": "Changing task state from Started to FinishedSuccess",
          "detailCreatedDate": "2021-10-19T14:34:17.039Z",
          "privileges": null
        }
      ],
      "scriptLogLocation": "<server.domain.ad>\\Script\\53c667f8-b6b9-431e-991e-fd9f9bf5d38f.20211019T103100.352-0400.6A297C9CD5AB2B27CEDD.log",
      "scriptLogSize": 9078282,
      "privileges": null
    },
    "nextExecution": "2021-10-19T15:30:59.439Z",
    "privileges": null
  },
  "name": "Reload task of Operations Monitor",
  "taskType": 0,
  "enabled": true,
  "taskSessionTimeout": 1440,
  "maxRetries": 0,
  "tags": [
    {
      "id": "cbc524d4-308e-4ff9-bb1a-743c5bc209ad",
      "name": "Monitoring Tools",
      "privileges": null
    }
  ],
  "privileges": null,
  "schemaPath": "ReloadTask"
}

We have a few high level elements:

  • id: ID of the reload task itself, this will vary between the environments
  • createdDate: The date the task was created, this will vary between the environments
  • modifiedDate: The date the task was last modified, this will vary between the environments
  • modifiedByUserName: The last user to modify the task, this will vary between the environments
  • app: The App details for the reload, this will vary between the environments since the key constraint it the App ID and it's a real pain to maintain the same App ID across environments as these IDs are intended to be random
  • operational: This is the ID of the operational (think of it as the handle between the actual schedule and the task), this ID will vary between the environments

It seems easier to me to just create a new one with the same schedule since you're rebuilding so many elements.

Are your reload tasks exclusively time based (i.e. reload every X minute / hour / day)? If so then you're going to want the SchemaEvent entity. In this example, I'll do a GET /qrs/schemaevent/full?filter=reloadTask.operational.id eq 8843c59f-d721-4379-a8e5-c5c38a3292ca to retrieve the details:

[
  {
    "id": "3ffa0ccd-5e71-4f0b-8143-9e5d717d59fb",
    "createdDate": "2019-06-25T19:25:59.44Z",
    "modifiedDate": "2019-06-25T19:25:59.44Z",
    "modifiedByUserName": "INTERNAL\\sa_repository",
    "timeZone": "UTC",
    "daylightSavingTime": 0,
    "startDate": "2019-06-25T15:30:59.439",
    "expirationDate": "9999-12-31T00:00:00",
    "schemaFilterDescription": [
      "* * - * * * * *"
    ],
    "incrementDescription": "0 1 0 0",
    "incrementOption": 1,
    "operational": {
      "id": "3accab99-2cef-4f47-9c0b-4151076b1bea",
      "nextExecution": "2021-10-19T15:30:59.439Z",
      "timesTriggered": 16169,
      "privileges": null
    },
    "name": "Reload Operations Monitor Schema",
    "enabled": true,
    "eventType": 0,
    "reloadTask": {
      "id": "3f053d35-e1e6-40f0-b3de-449c009ce99d",
      "operational": {
        "id": "8843c59f-d721-4379-a8e5-c5c38a3292ca",
        "lastExecutionResult": {
          "id": "cffa8426-e333-4138-b8cd-1f17228a6cfb",
          "executingNodeName": "<server.domain.ad>",
          "status": 7,
          "startTime": "2021-10-19T14:30:59.512Z",
          "stopTime": "2021-10-19T14:34:16.995Z",
          "duration": 197483,
          "fileReferenceID": "e0f7dcfc-2542-4873-8ff3-0471621e7491",
          "scriptLogAvailable": false,
          "details": [
            {
              "id": "6fe61b23-a114-4ce7-8303-977dab098334",
              "detailsType": 2,
              "message": "Changing task state from Triggered to Started",
              "detailCreatedDate": "2021-10-19T14:30:59.73Z",
              "privileges": null
            },
            {
              "id": "52f73b1c-f88a-4725-9dd3-d8eb79bb1eda",
              "detailsType": 2,
              "message": "Changing task state to Triggered",
              "detailCreatedDate": "2021-10-19T14:30:59.512Z",
              "privileges": null
            },
            {
              "id": "c457b3c5-e4cb-42c7-ace3-e628160e3749",
              "detailsType": 2,
              "message": "Trying to start task. Sending task to slave scheduler <server.domain.ad>",
              "detailCreatedDate": "2021-10-19T14:30:59.625Z",
              "privileges": null
            },
            {
              "id": "69ccb2a5-df02-4ad6-943d-d6163a5a0719",
              "detailsType": 2,
              "message": "Reference to scriptlog added",
              "detailCreatedDate": "2021-10-19T14:34:16.96Z",
              "privileges": null
            },
            {
              "id": "6361b448-4dd1-485d-b378-466e53561e6e",
              "detailsType": 2,
              "message": "Changing task state from Started to FinishedSuccess",
              "detailCreatedDate": "2021-10-19T14:34:17.039Z",
              "privileges": null
            }
          ],
          "scriptLogLocation": "<server.domain.ad>\\Script\\53c667f8-b6b9-431e-991e-fd9f9bf5d38f.20211019T103100.352-0400.6A297C9CD5AB2B27CEDD.log",
          "scriptLogSize": 9078282,
          "privileges": null
        },
        "nextExecution": "2021-10-19T15:30:59.439Z",
        "privileges": null
      },
      "name": "Reload task of Operations Monitor",
      "taskType": 0,
      "enabled": true,
      "taskSessionTimeout": 1440,
      "maxRetries": 0,
      "privileges": null
    },
    "userSyncTask": null,
    "externalProgramTask": null,
    "privileges": null,
    "schemaPath": "SchemaEvent"
  }
]

 

From there you have the schedule. You can then (on the target side):

1. Create the reload task with the right association
2. Create the schedule (example: https://community.qlik.com/t5/Integration-Extension-APIs/API-configure-trigger/td-p/1592969). 

View solution in original post

6 Replies
Maria_Halley
Support
Support

@sri_c003 

I'm moving this post to the Integration and API board I think you can get more answers there.

Levi_Turner
Employee
Employee

In all honesty, this would be a ship of theseus situation. Let's take an example reload task.

Get the reload task details (GET /qrs/reloadtask/{id}):

{
  "id": "3f053d35-e1e6-40f0-b3de-449c009ce99d",
  "createdDate": "2019-06-25T19:25:59.44Z",
  "modifiedDate": "2021-07-09T13:18:25.801Z",
  "modifiedByUserName": "<domain>\<userId>",
  "customProperties": [],
  "app": {
    "id": "53c667f8-b6b9-431e-991e-fd9f9bf5d38f",
    "name": "Operations Monitor",
    "appId": "",
    "publishTime": "2021-05-11T15:00:10.754Z",
    "published": true,
    "stream": {
      "id": "a70ca8a5-1d59-4cc9-b5fa-6e207978dcaf",
      "name": "Monitoring apps",
      "privileges": null
    },
    "savedInProductVersion": "12.969.2",
    "migrationHash": "21ecc792c56e18162f1785d3d41f28fdaced5c96",
    "availabilityStatus": 0,
    "privileges": null
  },
  "isManuallyTriggered": false,
  "operational": {
    "id": "8843c59f-d721-4379-a8e5-c5c38a3292ca",
    "lastExecutionResult": {
      "id": "cffa8426-e333-4138-b8cd-1f17228a6cfb",
      "executingNodeName": "<server.domain.ad>",
      "status": 7,
      "startTime": "2021-10-19T14:30:59.512Z",
      "stopTime": "2021-10-19T14:34:16.995Z",
      "duration": 197483,
      "fileReferenceID": "e0f7dcfc-2542-4873-8ff3-0471621e7491",
      "scriptLogAvailable": false,
      "details": [
        {
          "id": "6fe61b23-a114-4ce7-8303-977dab098334",
          "detailsType": 2,
          "message": "Changing task state from Triggered to Started",
          "detailCreatedDate": "2021-10-19T14:30:59.73Z",
          "privileges": null
        },
        {
          "id": "52f73b1c-f88a-4725-9dd3-d8eb79bb1eda",
          "detailsType": 2,
          "message": "Changing task state to Triggered",
          "detailCreatedDate": "2021-10-19T14:30:59.512Z",
          "privileges": null
        },
        {
          "id": "c457b3c5-e4cb-42c7-ace3-e628160e3749",
          "detailsType": 2,
          "message": "Trying to start task. Sending task to slave scheduler usral-ltu2.qliktech.com",
          "detailCreatedDate": "2021-10-19T14:30:59.625Z",
          "privileges": null
        },
        {
          "id": "69ccb2a5-df02-4ad6-943d-d6163a5a0719",
          "detailsType": 2,
          "message": "Reference to scriptlog added",
          "detailCreatedDate": "2021-10-19T14:34:16.96Z",
          "privileges": null
        },
        {
          "id": "6361b448-4dd1-485d-b378-466e53561e6e",
          "detailsType": 2,
          "message": "Changing task state from Started to FinishedSuccess",
          "detailCreatedDate": "2021-10-19T14:34:17.039Z",
          "privileges": null
        }
      ],
      "scriptLogLocation": "<server.domain.ad>\\Script\\53c667f8-b6b9-431e-991e-fd9f9bf5d38f.20211019T103100.352-0400.6A297C9CD5AB2B27CEDD.log",
      "scriptLogSize": 9078282,
      "privileges": null
    },
    "nextExecution": "2021-10-19T15:30:59.439Z",
    "privileges": null
  },
  "name": "Reload task of Operations Monitor",
  "taskType": 0,
  "enabled": true,
  "taskSessionTimeout": 1440,
  "maxRetries": 0,
  "tags": [
    {
      "id": "cbc524d4-308e-4ff9-bb1a-743c5bc209ad",
      "name": "Monitoring Tools",
      "privileges": null
    }
  ],
  "privileges": null,
  "schemaPath": "ReloadTask"
}

We have a few high level elements:

  • id: ID of the reload task itself, this will vary between the environments
  • createdDate: The date the task was created, this will vary between the environments
  • modifiedDate: The date the task was last modified, this will vary between the environments
  • modifiedByUserName: The last user to modify the task, this will vary between the environments
  • app: The App details for the reload, this will vary between the environments since the key constraint it the App ID and it's a real pain to maintain the same App ID across environments as these IDs are intended to be random
  • operational: This is the ID of the operational (think of it as the handle between the actual schedule and the task), this ID will vary between the environments

It seems easier to me to just create a new one with the same schedule since you're rebuilding so many elements.

Are your reload tasks exclusively time based (i.e. reload every X minute / hour / day)? If so then you're going to want the SchemaEvent entity. In this example, I'll do a GET /qrs/schemaevent/full?filter=reloadTask.operational.id eq 8843c59f-d721-4379-a8e5-c5c38a3292ca to retrieve the details:

[
  {
    "id": "3ffa0ccd-5e71-4f0b-8143-9e5d717d59fb",
    "createdDate": "2019-06-25T19:25:59.44Z",
    "modifiedDate": "2019-06-25T19:25:59.44Z",
    "modifiedByUserName": "INTERNAL\\sa_repository",
    "timeZone": "UTC",
    "daylightSavingTime": 0,
    "startDate": "2019-06-25T15:30:59.439",
    "expirationDate": "9999-12-31T00:00:00",
    "schemaFilterDescription": [
      "* * - * * * * *"
    ],
    "incrementDescription": "0 1 0 0",
    "incrementOption": 1,
    "operational": {
      "id": "3accab99-2cef-4f47-9c0b-4151076b1bea",
      "nextExecution": "2021-10-19T15:30:59.439Z",
      "timesTriggered": 16169,
      "privileges": null
    },
    "name": "Reload Operations Monitor Schema",
    "enabled": true,
    "eventType": 0,
    "reloadTask": {
      "id": "3f053d35-e1e6-40f0-b3de-449c009ce99d",
      "operational": {
        "id": "8843c59f-d721-4379-a8e5-c5c38a3292ca",
        "lastExecutionResult": {
          "id": "cffa8426-e333-4138-b8cd-1f17228a6cfb",
          "executingNodeName": "<server.domain.ad>",
          "status": 7,
          "startTime": "2021-10-19T14:30:59.512Z",
          "stopTime": "2021-10-19T14:34:16.995Z",
          "duration": 197483,
          "fileReferenceID": "e0f7dcfc-2542-4873-8ff3-0471621e7491",
          "scriptLogAvailable": false,
          "details": [
            {
              "id": "6fe61b23-a114-4ce7-8303-977dab098334",
              "detailsType": 2,
              "message": "Changing task state from Triggered to Started",
              "detailCreatedDate": "2021-10-19T14:30:59.73Z",
              "privileges": null
            },
            {
              "id": "52f73b1c-f88a-4725-9dd3-d8eb79bb1eda",
              "detailsType": 2,
              "message": "Changing task state to Triggered",
              "detailCreatedDate": "2021-10-19T14:30:59.512Z",
              "privileges": null
            },
            {
              "id": "c457b3c5-e4cb-42c7-ace3-e628160e3749",
              "detailsType": 2,
              "message": "Trying to start task. Sending task to slave scheduler <server.domain.ad>",
              "detailCreatedDate": "2021-10-19T14:30:59.625Z",
              "privileges": null
            },
            {
              "id": "69ccb2a5-df02-4ad6-943d-d6163a5a0719",
              "detailsType": 2,
              "message": "Reference to scriptlog added",
              "detailCreatedDate": "2021-10-19T14:34:16.96Z",
              "privileges": null
            },
            {
              "id": "6361b448-4dd1-485d-b378-466e53561e6e",
              "detailsType": 2,
              "message": "Changing task state from Started to FinishedSuccess",
              "detailCreatedDate": "2021-10-19T14:34:17.039Z",
              "privileges": null
            }
          ],
          "scriptLogLocation": "<server.domain.ad>\\Script\\53c667f8-b6b9-431e-991e-fd9f9bf5d38f.20211019T103100.352-0400.6A297C9CD5AB2B27CEDD.log",
          "scriptLogSize": 9078282,
          "privileges": null
        },
        "nextExecution": "2021-10-19T15:30:59.439Z",
        "privileges": null
      },
      "name": "Reload task of Operations Monitor",
      "taskType": 0,
      "enabled": true,
      "taskSessionTimeout": 1440,
      "maxRetries": 0,
      "privileges": null
    },
    "userSyncTask": null,
    "externalProgramTask": null,
    "privileges": null,
    "schemaPath": "SchemaEvent"
  }
]

 

From there you have the schedule. You can then (on the target side):

1. Create the reload task with the right association
2. Create the schedule (example: https://community.qlik.com/t5/Integration-Extension-APIs/API-configure-trigger/td-p/1592969). 

sri_c003
Partner - Creator II
Partner - Creator II
Author

@Levi_Turner Now that will take some time for me to assimilate what is mentioned. Let me check and get back to you. Thank you Levi for such detailed information.

RanOuerg
Creator
Creator

Hello @Levi ,

I need to get all the users Ids and Group AD from QRS but i don't find the script to do that 

Could you help me please ?

Thank you in advance.

Levi_Turner
Employee
Employee

@RanOuerg : I'd first take a step back and be sure we're on the same page of what Qlik Sense has. At the QRS layer, Qlik Sense will have any user metadata which was fetched from Active Directory via a User Directory Connector. So if we assume that the UDC is set up exactly as you require (it's fetching all users that you need information on), then we can query the QRS layer at /qrs/user/full (with or without a filter). Example response from my system:

[
  {
    "id": "a2d49057-4191-4c3a-9428-f16d48310ccf",
    "createdDate": "2016-09-09T03:46:32.92Z",
    "modifiedDate": "2024-02-22T03:39:23.951Z",
    "modifiedByUserName": "INTERNAL\\sa_repository",
    "customProperties": [],
    "userId": "ltu",
    "userDirectory": "QLIK",
    "userDirectoryConnectorName": "QLIK",
    "name": "Levi Turner",
    "roles": [
      "RootAdmin"
    ],
    "attributes": [
      {
        "id": "fdc3e68a-2c55-4a70-8c4c-cd43c1f7a5b1",
        "createdDate": "2024-02-22T03:39:23.951Z",
        "modifiedDate": "2024-02-22T03:39:23.951Z",
        "modifiedByUserName": "INTERNAL\\sa_repository",
        "attributeType": "Group",
        "attributeValue": "SG-OKTA-MyGroupName",
        "externalId": "CN=SG-OKTA-MyGroupName,DC=qlik,DC=com",
        "schemaPath": "User.Attribute"
    ],
    "inactive": false,
    "removedExternally": false,
    "blacklisted": false,
    "deleteProhibited": true,
    "tags": [],
    "favorites": [
      "a008d36d-ad6b-47bf-92c0-d6513b595081"
    ],
    "privileges": null,
    "schemaPath": "User"
  }
]

 

I've truncated the response because I am a member of many groups. But this will fetch the user's identity (userdirectory + userid) plus an attributes synchronized from a User Directory Connector.

RanOuerg
Creator
Creator

@Levi_Turner

Thank you for your response and explanation; it has been really helpful.

I understand that we cannot retrieve AD groups from the QRS layer.