Create, retrieve, update, and delete a wrangle table
This workflow sample demonstrates how to create, retrieve, update, and delete a wrangle table using the REST API.
Get the authorization token needed to execute the request with POST /api/auth/login.
Get the project ID from GET /api/projects.
Changesets are used in this workflow. For information on how to create and use changesets, see Changesets.
Wrangle tables are used to perform data preparation tasks such as cleaning, transforming, and enriching data before analysis. A wrangle table includes a source table as its child, and a series of wrangle operations.
Create a wrangle table
Endpoint: POST /api/dataServer/workspaces/{workspaceId}/pipelines/{pipelineId}/tables
Sample Request
- Request Headers
'Content-Type: application/json'
'Accept: application/json'
'X-MSTR-AuthToken: pgho7427r1e6p0tem7e677jivk'
'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754'
- Curl
curl -L -X POST 'https://demo.microstrategy.com/MicroStrategyLibrary/api/dataServer/workspaces/F380303209054FCFA52811989EA8C6F2/pipelines/9A4CA133630F4843A386C522C87FCD47/tables' \
-H 'X-MSTR-AuthToken: ceasprajdnuo9g4cnnh9sf1r8a' \
-H 'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754' \
-H 'Content-Type: application/json' \
-d '{
"name": "employees_upper",
"type": "wrangle",
"children": [
{
"name": "employees_upper",
"type": "source",
"importSource": {
"type": "single_table",
"dataSourceId": "E93B0C144F9EAF781E3993B5C439220D",
"namespace": "public",
"tableName": "employees_upper",
"sql": "",
"filterString": ""
}
}
],
"operations": [
{
"op": "splitColumn",
"category": "split",
"source": "manual",
"analyzed": true,
"regex2": false,
"mode": "lengths",
"separator": "",
"regex": false,
"maxColumns": -1,
"fieldLengths": [
1
],
"newColumnNames": [
"First Name",
"Last Name"
],
"removeOriginalColumn": true,
"columnName": "NAME",
"editMode": false
}
]
}'
Sample Response
- Response Body:
{
"id": "93FD7BC03D8147949B00D584E033A312",
"name": "employees_upper",
"type": "wrangle",
"columns": [
{
"id": "CE44F52D085642169CBB159BE3364EF0",
"name": "ID",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "C1C2C0A3064C4D409027CCB77620536A",
"name": "First Name",
"dataType": {
"type": "utf8_char"
},
"sourceDataType": {
"type": "utf8_char"
}
},
{
"id": "95B9336E0F1D41AD9B1D6A4B86210D7A",
"name": "Last Name",
"dataType": {
"type": "utf8_char"
},
"sourceDataType": {
"type": "utf8_char"
}
},
{
"id": "E202834082AF49BD93ADD2293E7EDE1D",
"name": "AGE",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "273FF9DB3E85400A88F8C89861894B9C",
"name": "DEPART",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "B7404EEEA2E44CAFAE3EF6359A09B4AC",
"name": "SALARY",
"dataType": {
"type": "double",
"precision": 10,
"scale": 2
},
"sourceDataType": {
"type": "double",
"precision": 10,
"scale": 2
}
},
{
"id": "5062E2F9BE5C4CB49C2237E0C510552C",
"name": "iD",
"dataType": {
"type": "int64",
"precision": 8,
"scale": 0
},
"sourceDataType": {
"type": "int64",
"precision": 8,
"scale": 0
}
}
],
"operations": [
{
"id": "88e2f455f5234ca587199e1491cc2396",
"op": "splitColumn",
"category": "split",
"source": "manual",
"analyzed": true,
"regex2": false,
"mode": "lengths",
"separator": "",
"regex": false,
"maxColumns": -1,
"fieldLengths": [1],
"newColumnNames": ["First Name", "Last Name"],
"newColumnIds": ["C1C2C0A3064C4D409027CCB77620536A", "95B9336E0F1D41AD9B1D6A4B86210D7A"],
"removeOriginalColumn": true,
"columnName": "NAME",
"editMode": false
}
],
"children": [
{
"id": "70F67D2792BA4C2C9CB703F766796668",
"name": "employees_upper",
"type": "source",
"columns": [
{
"id": "CE44F52D085642169CBB159BE3364EF0",
"name": "ID",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "607077D0569E49A392AC5DC704FBB386",
"name": "NAME",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "E202834082AF49BD93ADD2293E7EDE1D",
"name": "AGE",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "273FF9DB3E85400A88F8C89861894B9C",
"name": "DEPART",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "B7404EEEA2E44CAFAE3EF6359A09B4AC",
"name": "SALARY",
"dataType": {
"type": "double",
"precision": 10,
"scale": 2
},
"sourceDataType": {
"type": "double",
"precision": 10,
"scale": 2
}
},
{
"id": "5062E2F9BE5C4CB49C2237E0C510552C",
"name": "iD",
"dataType": {
"type": "int64",
"precision": 8,
"scale": 0
},
"sourceDataType": {
"type": "int64",
"precision": 8,
"scale": 0
}
}
],
"importSource": {
"type": "single_table",
"dataSourceId": "E93B0C144F9EAF781E3993B5C439220D",
"namespace": "public",
"tableName": "employees_upper",
"sql": "",
"filterString": ""
},
"originalSchema": "{\"type\":\"struct\",\"fields\":[{\"name\":\"ID\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"ID\",\"scale\":0}},{\"name\":\"NAME\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"NAME\",\"scale\":0}},{\"name\":\"AGE\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"AGE\",\"scale\":0}},{\"name\":\"DEPART\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"DEPART\",\"scale\":0}},{\"name\":\"SALARY\",\"type\":\"double\",\"nullable\":true,\"metadata\":{\"precision\":10,\"dssType\":\"double\",\"name\":\"SALARY\",\"scale\":2}},{\"name\":\"iD\",\"type\":\"long\",\"nullable\":true,\"metadata\":{\"precision\":19,\"dssType\":\"int64\",\"name\":\"iD\",\"scale\":0}}]}"
}
]
}
- Response Code: 201 (Success: Created)
Retrieve a wrangle table
Endpoint: GET /api/dataServer/workspaces/{workspaceId}/pipelines/{pipelineId}/tables/{tableId}
Sample Request
- Request Headers
'Content-Type: application/json'
'Accept: application/json'
'X-MSTR-AuthToken: pgho7427r1e6p0tem7e677jivk'
'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754'
- Curl
curl -L -X GET 'https://demo.microstrategy.com/MicroStrategyLibrary/api/dataServer/workspaces/F380303209054FCFA52811989EA8C6F2/pipelines/9A4CA133630F4843A386C522C87FCD47/tables/93FD7BC03D8147949B00D584E033A312' \
-H 'X-MSTR-AuthToken: ceasprajdnuo9g4cnnh9sf1r8a' \
-H 'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754'
Sample Response
- Response Body:
{
"id": "93FD7BC03D8147949B00D584E033A312",
"name": "employees_upper",
"type": "wrangle",
"columns": [
{
"id": "CE44F52D085642169CBB159BE3364EF0",
"name": "ID",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "C1C2C0A3064C4D409027CCB77620536A",
"name": "First Name",
"dataType": {
"type": "utf8_char"
},
"sourceDataType": {
"type": "utf8_char"
}
},
{
"id": "95B9336E0F1D41AD9B1D6A4B86210D7A",
"name": "Last Name",
"dataType": {
"type": "utf8_char"
},
"sourceDataType": {
"type": "utf8_char"
}
},
{
"id": "E202834082AF49BD93ADD2293E7EDE1D",
"name": "AGE",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "273FF9DB3E85400A88F8C89861894B9C",
"name": "DEPART",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "B7404EEEA2E44CAFAE3EF6359A09B4AC",
"name": "SALARY",
"dataType": {
"type": "double",
"precision": 10,
"scale": 2
},
"sourceDataType": {
"type": "double",
"precision": 10,
"scale": 2
}
},
{
"id": "5062E2F9BE5C4CB49C2237E0C510552C",
"name": "iD",
"dataType": {
"type": "int64",
"precision": 8,
"scale": 0
},
"sourceDataType": {
"type": "int64",
"precision": 8,
"scale": 0
}
}
],
"operations": [
{
"id": "88e2f455f5234ca587199e1491cc2396",
"op": "splitColumn",
"category": "split",
"source": "manual",
"analyzed": true,
"regex2": false,
"mode": "lengths",
"separator": "",
"regex": false,
"maxColumns": -1,
"fieldLengths": [1],
"newColumnNames": ["First Name", "Last Name"],
"newColumnIds": ["C1C2C0A3064C4D409027CCB77620536A", "95B9336E0F1D41AD9B1D6A4B86210D7A"],
"removeOriginalColumn": true,
"columnName": "NAME",
"editMode": false
}
],
"children": [
{
"id": "70F67D2792BA4C2C9CB703F766796668",
"name": "employees_upper",
"type": "source",
"columns": [
{
"id": "CE44F52D085642169CBB159BE3364EF0",
"name": "ID",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "607077D0569E49A392AC5DC704FBB386",
"name": "NAME",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "E202834082AF49BD93ADD2293E7EDE1D",
"name": "AGE",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "273FF9DB3E85400A88F8C89861894B9C",
"name": "DEPART",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "B7404EEEA2E44CAFAE3EF6359A09B4AC",
"name": "SALARY",
"dataType": {
"type": "double",
"precision": 10,
"scale": 2
},
"sourceDataType": {
"type": "double",
"precision": 10,
"scale": 2
}
},
{
"id": "5062E2F9BE5C4CB49C2237E0C510552C",
"name": "iD",
"dataType": {
"type": "int64",
"precision": 8,
"scale": 0
},
"sourceDataType": {
"type": "int64",
"precision": 8,
"scale": 0
}
}
],
"importSource": {
"type": "single_table",
"dataSourceId": "E93B0C144F9EAF781E3993B5C439220D",
"namespace": "public",
"tableName": "employees_upper",
"sql": "",
"filterString": ""
},
"originalSchema": "{\"type\":\"struct\",\"fields\":[{\"name\":\"ID\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"ID\",\"scale\":0}},{\"name\":\"NAME\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"NAME\",\"scale\":0}},{\"name\":\"AGE\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"AGE\",\"scale\":0}},{\"name\":\"DEPART\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"DEPART\",\"scale\":0}},{\"name\":\"SALARY\",\"type\":\"double\",\"nullable\":true,\"metadata\":{\"precision\":10,\"dssType\":\"double\",\"name\":\"SALARY\",\"scale\":2}},{\"name\":\"iD\",\"type\":\"long\",\"nullable\":true,\"metadata\":{\"precision\":19,\"dssType\":\"int64\",\"name\":\"iD\",\"scale\":0}}]}"
}
]
}
- Response Code: 200 (Success: OK)
Update a wrangle table
You can update name and operations of a wrangle table.
Endpoint: PATCH /api/dataServer/workspaces/{workspaceId}/pipelines/{pipelineId}/tables/{tableId}
Sample Request
- Request Headers
'Content-Type: application/json'
'Accept: application/json'
'X-MSTR-AuthToken: pgho7427r1e6p0tem7e677jivk'
'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754'
- Curl
curl -L -X PATCH 'https://demo.microstrategy.com/MicroStrategyLibrary/api/dataServer/workspaces/F380303209054FCFA52811989EA8C6F2/pipelines/9A4CA133630F4843A386C522C87FCD47/tables/93FD7BC03D8147949B00D584E033A312' \
-H 'X-MSTR-AuthToken: ceasprajdnuo9g4cnnh9sf1r8a' \
-H 'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754' \
-H 'Content-Type: application/json' \
-d '{
"name": "updated wrangle table",
"type": "wrangle",
"operations": []
}'
Sample Response
- Response Body:
{
"id": "93FD7BC03D8147949B00D584E033A312",
"name": "employees_upper",
"type": "wrangle",
"columns": [
{
"id": "CE44F52D085642169CBB159BE3364EF0",
"name": "ID",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "607077D0569E49A392AC5DC704FBB386",
"name": "NAME",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "E202834082AF49BD93ADD2293E7EDE1D",
"name": "AGE",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "273FF9DB3E85400A88F8C89861894B9C",
"name": "DEPART",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "B7404EEEA2E44CAFAE3EF6359A09B4AC",
"name": "SALARY",
"dataType": {
"type": "double",
"precision": 10,
"scale": 2
},
"sourceDataType": {
"type": "double",
"precision": 10,
"scale": 2
}
},
{
"id": "5062E2F9BE5C4CB49C2237E0C510552C",
"name": "iD",
"dataType": {
"type": "int64",
"precision": 8,
"scale": 0
},
"sourceDataType": {
"type": "int64",
"precision": 8,
"scale": 0
}
}
],
"operations": [],
"children": [
{
"id": "70F67D2792BA4C2C9CB703F766796668",
"name": "employees_upper",
"type": "source",
"columns": [
{
"id": "CE44F52D085642169CBB159BE3364EF0",
"name": "ID",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "607077D0569E49A392AC5DC704FBB386",
"name": "NAME",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "E202834082AF49BD93ADD2293E7EDE1D",
"name": "AGE",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "273FF9DB3E85400A88F8C89861894B9C",
"name": "DEPART",
"dataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
},
"sourceDataType": {
"type": "utf8_char",
"precision": 50,
"scale": 0
}
},
{
"id": "B7404EEEA2E44CAFAE3EF6359A09B4AC",
"name": "SALARY",
"dataType": {
"type": "double",
"precision": 10,
"scale": 2
},
"sourceDataType": {
"type": "double",
"precision": 10,
"scale": 2
}
},
{
"id": "5062E2F9BE5C4CB49C2237E0C510552C",
"name": "iD",
"dataType": {
"type": "int64",
"precision": 8,
"scale": 0
},
"sourceDataType": {
"type": "int64",
"precision": 8,
"scale": 0
}
}
],
"importSource": {
"type": "single_table",
"dataSourceId": "E93B0C144F9EAF781E3993B5C439220D",
"namespace": "public",
"tableName": "employees_upper",
"sql": "",
"filterString": ""
},
"originalSchema": "{\"type\":\"struct\",\"fields\":[{\"name\":\"ID\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"ID\",\"scale\":0}},{\"name\":\"NAME\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"NAME\",\"scale\":0}},{\"name\":\"AGE\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"AGE\",\"scale\":0}},{\"name\":\"DEPART\",\"type\":\"string\",\"nullable\":true,\"metadata\":{\"precision\":50,\"dssType\":\"utf8_char\",\"name\":\"DEPART\",\"scale\":0}},{\"name\":\"SALARY\",\"type\":\"double\",\"nullable\":true,\"metadata\":{\"precision\":10,\"dssType\":\"double\",\"name\":\"SALARY\",\"scale\":2}},{\"name\":\"iD\",\"type\":\"long\",\"nullable\":true,\"metadata\":{\"precision\":19,\"dssType\":\"int64\",\"name\":\"iD\",\"scale\":0}}]}"
}
]
}
- Response Code: 200 (Success: OK)
Delete a wrangle table
Endpoint: DELETE /api/dataServer/workspaces/{workspaceId}/pipelines/{pipelineId}/tables/{tableId}
Sample Request
- Request Headers
'Content-Type: application/json'
'Accept: application/json'
'X-MSTR-AuthToken: pgho7427r1e6p0tem7e677jivk'
'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754'
- Curl
curl -L -X DELETE 'https://demo.microstrategy.com/MicroStrategyLibrary/api/dataServer/workspaces/F380303209054FCFA52811989EA8C6F2/pipelines/9A4CA133630F4843A386C522C87FCD47/tables/93FD7BC03D8147949B00D584E033A312' \
-H 'X-MSTR-AuthToken: ceasprajdnuo9g4cnnh9sf1r8a' \
-H 'X-MSTR-ProjectID: B7CA92F04B9FAE8D941C3E9B7E0CD754'
Sample Response
-
Response Body: (empty)
-
Response Code: 204 (Success: No Content)