Skip to content

Data Exchange Service – Samples

The examples below exemplify how to use the provided endpoints:

In order to specify the visibility of a resource refer to Data Exchange Service Visibility Spaces

Uploading a file in the tenant root space

The tenant root space is defined as the root group that contains files and folders accessible to all the users within the tenant.

Request:

1
2
POST  /api/dataexchange/v3/files
X-XSRF-TOKEN: b73deb0d-feb2-4183-b4c6-a96abe62a44d

Form data:

1
2
metadata :{"name": "custom_file_name.txt", "parentId": "_PUBLIC_ROOT_ID", "type":"CSV"}
file : <file_content_byte_array>

Response:

1
2
3
4
5
6
7
8
9
{
    "resourceId": "327e0baa-f5ba-4d24-af11-8d85de8007e9",
    "name": "custom_file_name.txt",
    "parentId": "_PUBLIC_ROOT_ID",
    "type": "CSV",
    "sizeInBytes": 8584808,
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Uploading a file in the user root space

The user root space is defined as the root group that contains files and folders only accessible to a specific user within the tenant.

Request:

1
2
POST  /api/dataexchange/v3/files
X-XSRF-TOKEN: b73deb0d-feb2-4183-b4c6-a96abe62a44d

Form data:

1
2
metadata :{"name": "custom_file_name.txt", "parentId": "_PRIVATE_ROOT_ID", "type":"CSV"}
file : <file_content_byte_array>

Response:

1
2
3
4
5
6
7
8
9
{
    "resourceId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "name": "custom_file_name.txt",
    "parentId": "_PRIVATE_ROOT_ID",
    "type": "CSV",
    "sizeInBytes": 8584808,
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Creating a directory in the tenant root space

The tenant root space is defined as the root group that contains files and folders accessible to all the users within the tenant.

Request:

1
2
3
POST  /api/dataexchange/v3/directories
X-XSRF-TOKEN:cade03ca-370c-49fd-9acd-b879368263d6
metadata :{"name": "public_directory", "parentId": "_PUBLIC_ROOT_ID"}

Response:

1
2
3
4
5
6
7
{
    "resourceId": "1821dcbb-13c2-4112-b4c3-0cbb799dce54",
    "name": "public_directory",
    "parentId": "_PUBLIC_ROOT_ID",
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Creating a directory in the user root space

The user root space is defined as the root group that contains files and folders only accessible to a specific user within the tenant.

Request:

1
2
3
POST  /api/dataexchange/v3/directories
X-XSRF-TOKEN:cade03ca-370c-49fd-9acd-b879368263d6
metadata :{"name": "private_directory", "parentId": "_PRIVATE_ROOT_ID"}

Response:

1
2
3
4
5
6
7
{
    "resourceId": "1821dcb1-13c2-4112-b4c3-0cbb799dce54",
    "name": "private_directory",
    "parentId": "_PRIVATE_ROOT_ID",
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Deleting a file

Request:

1
2
DELETE /api/dataexchange/v3/files/327e0baa-f5b1-4df4-af11-8d85de8007e9 HTTP/1.1
X-XSRF-TOKEN: b73deb0d-feb2-4183-b4c6-a96abe62a44d

Deleting a directory

Request:

1
2
DELETE /api/dataexchange/v3/directories/1821dcbb-13c2-4112-b4c3-0cbb799dce54 HTTP/1.1
X-XSRF-TOKEN: b73deb0d-feb2-4183-b4c6-a96abe62a44d

Listing a directory contents

Request:

1
GET /api/dataexchange/v3/directories/_PRIVATE_ROOT_ID
1
GET /api/dataexchange/v3/directories/_PUBLIC_ROOT_ID
1
GET /api/dataexchange/v3/directories/1821dcbb-13c2-4112-b4c3-0cbb799dce54

Response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
    "files": [
        {
            "id": "f6214934-6f2f-416f-87e1-1fee5c31d91b",
            "parentId": "1821dcbb-13c2-4112-b4c3-0cbb799dce54",
            "name": "some_file.txt",
            "type": "TXT",
            "modifiedBy": "a_user@siemens.com",
            "sizeInBytes": 8584808,
            "lastModified": "2018-07-12T13:07:26.966"
        },
        {
            "id": "c8a849e2-801c-47f0-b648-4efb41101b78",
            "parentId": "1821dcbb-13c2-4112-b4c3-0cbb799dce54",
            "name": "another_file.csv",
            "type": "CSV",
            "modifiedBy": "some.name@siemens.com",
            "sizeInBytes": 563433,
            "lastModified": "2018-07-09T13:53:36.213"
        }
    ],
    "directories": [
        {
            "id": "17ee9f30-501c-4efa-bdcd-8bbf52d87941",
            "parentId": "1821dcbb-13c2-4112-b4c3-0cbb799dce54",
            "name": "dir1",
            "modifiedBy": "some.name@siemens.com"
        },
        {
            "id": "1891dcbb-13c2-4111-b4c3-0cbb799dce54",
            "parentId": "1821dcbb-13c2-4112-b4c3-0cbb799dce54",
            "name": "dir2",
            "modifiedBy": "a_user@siemens.com"
        }
    ]
}

Note

The parentId field will take the values of _PUBLIC_ROOT_ID or _PRIVATE_ROOT_ID or the resource id for which the listing is performed

Retrieving a directory's properties

Request:

1
GET  /api/dataexchange/v3/directories/327e0baa-f5b1-4df4-af11-8d85de8007e9

Response:

1
2
3
4
5
6
7
{
    "resourceId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "name": "public_dir.txt",
    "parentId": "_PUBLIC_ROOT_ID",
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Retrieving a file's properties

Request:

1
GET  /api/dataexchange/v3/files/327e0baa-f5b1-4df4-af11-8d85de8007e9/properties

Response:

1
2
3
4
5
6
7
8
9
{
    "resourceId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "name": "custom_file_name.txt",
    "parentId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "type": "CSV",
    "sizeInBytes": 8584808,
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Downloading a file

Request:

1
2
3
GET /api/dataexchange/v3/files/327e0baa-f5b1-4df4-af11-8d85de8007e9
Content-Type: application/json
Accept: application/octet-stream

Response:

1
<file_byte_array>

Updating/Replacing a file's content

Request:

1
2
3
GET /api/dataexchange/v3/files/327e0baa-f5b1-4df4-af11-8d85de8007e9
X-XSRF-TOKEN: b73deb0d-feb2-4183-b4c6-a96abe62a44d
Accept: application/octet-stream

Form data:

1
file: <file_byte_array>

Response:

1
2
3
4
5
6
7
8
9
{
    "resourceId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "name": "custom_file_name.txt",
    "parentId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "type": "CSV",
    "sizeInBytes": 8584808,
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Renaming/Moving/Updating type or visibility for a file

If a file's visibility is public, the file is visible for all users within the tenant. A file can be made public by the following actions:

  • Placing it into the _PUBLIC_ROOT_ID
  • Placing it in a directory that is public

Analogously, use private folders for making a file private.

Request:

1
2
3
PATCH /api/dataexchange/v3/files/327e0baa-f5b1-4df4-af11-8d85de8007e9
X-XSRF-TOKEN: b73deb0d-feb2-4183-b4c6-a96abe62a44d
Accept: application/octet-stream

Body:

1
{"name": "renamed_filename.txt", "parentId":"_PUBLIC_ROOT_ID", "type":"Parquet"}

Response:

1
2
3
4
5
6
7
8
9
{
    "resourceId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "name": "custom_file_name.txt",
    "parentId": "_PUBLIC_ROOT_ID",
    "type": "Parquet",
    "sizeInBytes": 8584808,
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Renaming/Moving/Updating visibility for a directory

If a directory's visibility is public, the file is visible for all users within the tenant. A directory can be made public by the following actions:

  • Placing it into the _PUBLIC_ROOT_ID
  • Placing it in a directory that is public

Analogously, use private folders for making a directory private.

Request:

1
2
3
PATCH /api/dataexchange/v3/directories/327e0baa-f5b1-4df4-af11-8d85de8007e9
X-XSRF-TOKEN: b73deb0d-feb2-4183-b4c6-a96abe62a44d
Accept: application/octet-stream

Body:

1
{"name": "renamed_directory", "parentId":"_PUBLIC_ROOT_ID"}

Response:

1
2
3
4
5
6
7
{
    "resourceId": "327e0baa-f5b1-4df4-af11-8d85de8007e9",
    "name": "renamed_directory",
    "parentId": "_PUBLIC_ROOT_ID",
    "modifiedDate": "2018-07-12T13:11:29.180",
    "modifiedBy": "a_user@siemens.com"
}

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.