Skip to content

Create data files in Qlik Cloud

Overview

In this tutorial, you are going to learn how to create a new data file via direct file upload, and how to duplicate an existing data file.

Requirements

Note: The cURL examples in this tutorial show the command syntax for Windows Command Prompt. If you are using another command line interface, different syntax may be required for line continuation. You may also need to adjust the number and type of quotes surrounding the parameters and their values.

Variable substitution and vocabulary

Throughout this tutorial, variables will be used to communicate value placement. The variable substitution format is <VARIABLE_NAME>. Here is a list of variables referred to in this tutorial.

VariableDescription
<HOSTNAME>The hostname for the initial tenant created during account onboarding. Such as tenantname.region.qlikcloud.com.
<ACCESS_TOKEN>A bearer token for authorizing https requests to the <HOSTNAME> tenant. Can be an API key, or a token generated via an OAuth client.
<OAUTH_CLIENT_ID>An OAuth client ID for authorizing requests if using the platform SDK.
<OAUTH_CLIENT_SECRET>An OAuth client secret for authorizing requests if using the platform SDK.
<PATH_TO_DATA_FILE>The path on your local system to a data file, such as /path/to/datafile.csv.
<DATA_FILE_NAME>The name that will be displayed for the uploaded data file, for example mydatafile.csv.
<SPACE_NAME>The name of the shared space you’ll create data files in.
<SPACE_ID>The ID of the shared space <SPACE_NAME>.
<CONNECTION_ID>The ID for the data file connection in <SPACE_NAME>.
<DATA_FILE_ID>The ID for the data file.
<DATA_SET_ID>The ID for the data set generated from an uploaded data file.

Upload a data file

Uploading a data file from your local system to Qlik Cloud can be done using the Data files API. This tutorial series walks you through creating a new space, uploading files, updating files, and deleting them.

Create a space

Spaces are logical containers used to store content in Qlik Cloud tenants, and each space will automatically generate a data files connection, to which you can upload data. By default, if a space is not specified, the data file will be uploaded to your personal space.

First, create a shared space using the Spaces API with the POST method. The name of the space and the type of space is passed in the body of the request.

The response should look something like this if using qlik-cli:

Example qlik-cli response
{
  "createdAt": "2023-04-25T11:07:58.974Z",
  "createdBy": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
  "description": "",
  "id": "<SPACE_ID>",
  "meta": {
    "actions": [
      "create",
      "delete",
      "read",
      "update"
    ],
    "assignableRoles": [
      "consumer",
      "dataconsumer",
      "facilitator",
      "producer"
    ],
    "roles": []
  },
  "name": "<SPACE_NAME>",
  "ownerId": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
  "tenantId": "G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk",
  "type": "shared",
  "updatedAt": "2023-04-25T11:07:58.974Z"
}

Take note of the <SPACE_ID> as it will be needed to find the connection ID for the data files connection that was automatically created in the space.

Get the connection ID

A data files connection allows you to interact with files uploaded to a space. To upload a data file to a space, you need to know the ID of the Datafiles connection in that space, which is unique to that space. To get the connection ID, use the Data files API.

The response should look something like this if using qlik-cli:

Example qlik-cli response
[
  {
    "id": "<CONNECTION_ID>",
    "privileges": [
      "read"
    ],
    "qArchitecture": 0,
    "qConnectStatement": "CUSTOM CONNECT TO \"provider=qix-datafiles.exe;path=<SPACE_NAME>:datafiles;\"",
    "qEngineObjectID": "967ee1bf-a2a8-4a50-81be-9574c75f3fb7",
    "qID": "967ee1bf-a2a8-4a50-81be-9574c75f3fb7",
    "qLogOn": 0,
    "qName": "DataFiles",
    "qType": "qix-datafiles.exe",
    "space": "<SPACE_ID>",
    "tenant": "G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk"
  }
]

From the response in the example, capture the <CONNECTION_ID>, which you will use with the file upload request.

Upload a new data file

To upload a new data file to a space, use the Data files API with the POST method. Add the filename and path of the local data file to the body of the request using the multipart/form-data format. You also need to pass the destination filename and connection ID in the body of the request, as shown in the following example.

Note: If you are uploading data files larger than 500 MB, you will need to adjust the upload approach. This is because larger files must be uploaded to the temp-contents API, which supports chunked uploads for these larger files. When using qlik-cli, you add an additional flag, but for raw API approaches you will need to amend your code.

The response should look something like this if using qlik-cli:

Example qlik-cli response
{
  "createdDate": "2023-04-25T11:50:37.2046053Z",
  "id": "<DATA_FILE_ID>",
  "modifiedDate": "2023-04-25T11:50:37.4226807Z",
  "name": "<DATA_FILE_NAME>",
  "ownerId": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
  "size": 43589,
  "spaceId": "<SPACE_ID>"
}

The response indicates that the data file has been successfully uploaded to the tenant in the designated space, with the specified name.

Retrieve the data set for a data file

To retrieve the data set for a data file, you can use the Items API to retrieve the data set, and then call the Data sets API for metadata generated on the file.

Retrieve the data set ID

The response should look something like this if using qlik-cli:

Example qlik-cli response
[
  {
    "actions": [
      ...
    ],
    "collectionIds": [],
    "createdAt": "2023-05-12T09:56:27Z",
    "creatorId": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
    "id": "645e0d4beea64e3da17d780c",
    "isFavorited": false,
    "itemViews": {},
    "meta": {
      "actions": [
        ...
      ],
      "collections": [],
      "isFavorited": false,
      "tags": []
    },
    "name": "<DATA_FILE_NAME>",
    "ownerId": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
    "resourceAttributes": {
      "appType": "QIX-DF",
      "dataStoreName": "DataFilesStore",
      "dataStoreType": "qix-datafiles",
      "qri": "qdf:qix-datafiles:G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk:sid@6447b48e8f1ff8bae0abc06d:<DATA_FILE_NAME>",
      "secureQri": "qri:qdf:space://SMRdll7Sm5pgfaAla9DW3mnEhZa9vc2qbqS6mDASQcE#P5MFmetJPJ7ihdQzzEwsnmUKEyaoz60tREjwEnesS_o",
      "sourceSystemId": "QIX-DF_d987e774-b30a-4eec-b74b-48fd0e61858f",
      "technicalDescription": "",
      "technicalName": "<DATA_FILE_NAME>",
      "type": "xml",
      "version": "1"
    },
    "resourceCreatedAt": "2023-05-12T09:56:26Z",
    "resourceCustomAttributes": null,
    "resourceId": "<DATA_SET_ID>",
    "resourceReloadEndTime": "",
    "resourceReloadStatus": "",
    "resourceSize": {
      "appFile": 0,
      "appMemory": 0
    },
    "resourceSubType": "qix-df",
    "resourceType": "dataset",
    "resourceUpdatedAt": "2023-05-12T09:56:33Z",
    "spaceId": "<SPACE_ID>",
    "tenantId": "G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk",
    "updatedAt": "2023-05-12T09:56:33Z",
    "updaterId": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn"
  }
]

The response indicates that the data set exists. There are multiple IDs in this response - the relevant ID for the data set is in the resourceId attribute. Capture this as <DATA_SET_ID>.

Retrieve the data set metadata

The response should look something like this if using qlik-cli:

Example qlik-cli response
{
  "classifications": {
    "personalInformation": [],
    "sensitiveInformation": []
  },
  "createdBy": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
  "createdTime": "2023-05-12T09:56:26.920Z",
  "dataAssetInfo": {
    "dataStoreInfo": {
      "id": "601c40bbc1fdfb4324a75a4d",
      "name": "DataFilesStore",
      "type": "qix-datafiles"
    },
    "id": "64497d05c67d6117d0f64da1",
    "name": "<SPACE_NAME>"
  },
  "description": "",
  "id": "<DATA_SET_ID>",
  "lastModifiedBy": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
  "lastModifiedTime": "2023-05-12T09:56:33.123Z",
  "name": "<DATA_FILE_NAME>",
  "operational": {
    "contentUpdated": true,
    "lastLoadTime": "2023-05-12T09:56:26.920Z",
    "lastUpdateTime": "2023-05-12T09:56:27.337Z",
    "location": "40f8dab3-6965-4d99-8695-59a5c1151d56",
    "logMessage": "{\n  \"cloudEventsVersion\": \"0.1\",\n  \"source\": \"com.qlik/qix-datafiles\",\n  \"contentType\": \"application/json\",\n  \"eventID\": \"40f8dab3-6965-4d99-8695-59a5c1151d56\",\n  \"eventType\": \"com.qlik.datafile.created\
",\n  \"eventTypeVersion\": \"0.0.1\",\n  \"eventTime\": \"2023-05-12T09:56:27.3414906Z\",\n  \"extensions\": {\n    \"tenantId\": \"G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk\",\n    \"userId\": \"CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn\",\n    \"header\": {\n
    \"traceparent\": [\n        \"00-0000000000000000b96c01cc6a74cf19-6676b3130bc7530b-01\"\n      ]\n    }\n  },\n  \"data\": {\n    \"id\": \"d987e774-b30a-4eec-b74b-48fd0e61858f\",\n    \"name\": \"<DATA_FILE_NAME>\",\n    \"createdDate\": \"2
023-05-12T09:56:26.9205165Z\",\n    \"modifiedDate\": \"2023-05-12T09:56:27.3378401Z\",\n    \"createdByUser\": \"CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn\",\n    \"modifiedByUser\": \"CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn\",\n    \"ownerId\": \"CBg-NdDpqyFZI
HRxylm03Pr2Gp3U7Ynn\",\n    \"spaceId\": \"<SPACE_ID>\",\n    \"size\": 85316,\n    \"contentUpdated\": true,\n    \"isInternal\": false,\n    \"qri\": \"qri:qdf:space://SMRdll7Sm5pgfaAla9DW3mnEhZa9vc2qbqS6mDASQcE#P5MFmetJPJ7ihdQzzE
wsnmUKEyaoz60tREjwEnesS_o\"\n  },\n  \"messageTopic\": \"system-events.datafiles/Created/G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk/d987e774-b30a-4eec-b74b-48fd0e61858f\"\n}",
    "rowCount": 1040,
    "size": 85316,
    "status": "com.qlik.datafile.created"
  },
  "ownerId": "CBg-NdDpqyFZIHRxylm03Pr2Gp3U7Ynn",
  "properties": {
    "ModifiedByProfileService": false
  },
  "qri": "qdf:qix-datafiles:G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk:sid@6447b48e8f1ff8bae0abc06d:<DATA_FILE_NAME>",
  "schema": {
    "dataFields": [
      {
        "dataType": {
          "properties": {
            "qType": "U",
            "qUseThou": 0,
            "qnDec": 0
          },
          "type": "INTEGER"
        },
        "encrypted": false,
        "index": 0,
        "name": "Id",
        "nullable": false,
        "orphan": false,
        "primaryKey": false,
        "sensitive": false,
        "tags": [
          "$integer",
          "$numeric"
        ]
      },
      {
        "dataType": {
          "properties": {
            "qType": "U",
            "qUseThou": 0,
            "qnDec": 0
          },
          "type": "STRING"
        },
        "encrypted": false,
        "index": 1,
        "name": "TagName",
        "nullable": false,
        "orphan": false,
        "primaryKey": false,
        "sensitive": false,
        "tags": [
          "$text",
          "$ascii"
        ]
      },
      {
        "dataType": {
          "properties": {
            "qType": "U",
            "qUseThou": 0,
            "qnDec": 0
          },
          "type": "INTEGER"
        },
        "encrypted": false,
        "index": 2,
        "name": "Count",
        "nullable": false,
        "orphan": false,
        "primaryKey": false,
        "sensitive": false,
        "tags": [
          "$integer",
          "$numeric"
        ]
      },
      {
        "dataType": {
          "properties": {
            "qType": "U",
            "qUseThou": 0,
            "qnDec": 0
          },
          "type": "INTEGER"
        },
        "encrypted": false,
        "index": 3,
        "name": "ExcerptPostId",
        "nullable": false,
        "orphan": false,
        "primaryKey": false,
        "sensitive": false
      },
      {
        "dataType": {
          "properties": {
            "qType": "U",
            "qUseThou": 0,
            "qnDec": 0
          },
          "type": "INTEGER"
        },
        "encrypted": false,
        "index": 4,

        "name": "WikiPostId",
        "nullable": false,
        "orphan": false,
        "primaryKey": false,
        "sensitive": false
      }
    ],
    "effectiveDate": "2023-05-12T09:56:33.149Z",
    "loadOptions": {
      "qDataFormat": {
        "qCodePage": 0,
        "qDelimiter": {
          "qNumber": 0
        },
        "qHeaderSize": 0,
        "qRecordSize": 0,
        "qTabSize": 0,
        "qType": "XML"
      }
    },
    "overrideSchemaAnomalies": false
  },
  "secureQri": "qri:qdf:space://SMRdll7Sm5pgfaAla9DW3mnEhZa9vc2qbqS6mDASQcE#P5MFmetJPJ7ihdQzzEwsnmUKEyaoz60tREjwEnesS_o",
  "spaceId": "<SPACE_ID>",
  "technicalDescription": "",
  "technicalName": "<DATA_FILE_NAME>",
  "tenantId": "G8r1kgLOO2OQDx8twJrgLJN7MchF3hDk",
  "type": "xml",
  "version": 1
}

Duplicate a data file

You can duplicate (copy) data files already in Qlik Cloud. This is done using the import command, but passing the ID of the existing data file instead of a new file.

Ensure that you use a new <DATA_FILE_NAME> for the duplicated file, unless you are moving it to a different space, as data file names must be unique per space.

Successfully duplicating the data file will result in the same response as creating a new data file.

Next steps

Now that you know how to create and copy data files, why not look at how to update existing data files?

Was this page helpful?