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:

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

Form data:

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

Response:

{
    "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:

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

Form data:

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

Response:

{
    "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:

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

Response:

{
    "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:

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

Response:

{
    "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:

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:

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:

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

Response:

{
    "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 accepts 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:

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

Response:

{
    "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:

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

Response:

{
    "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:

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

Response:

<file_byte_array>

Updating/Replacing a file's content

Request:

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

Form data:

file: <file_byte_array>

Response:

{
    "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:

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

Body:

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

Response:

{
    "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:

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

Body:

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

Response:

{
    "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"
}

Last update: December 16, 2021

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