Create a table API JSON Body
AnsweredHi,
I have some questions regarding the JSON body used in the "Create a table" API call.
1. "datasetUpdated": "2019-08-24T14:15:22Z", I want to use the call to set up the column structure and define data type, I am not intend to immediately import a file. Is this a required value to be entered? If it's, can I use python's datetime function to get a current time in UTC and format it to the format?
2. "hierarchyMetadata" and "metadata" in columns, the table I am creating have no such information, can I use {} or the word "None" to satisfy?
3. "uniqueTableConstraints", also if I don't have any info to provide, can I just use [] to satisfy this requirement.
For the 2 &3, I use the "Retrieve a single table" call to the table information from a table I created via UI and the returned information are shown as either None, "{}" or "[]".
-
Hi Jase the Ace, please see TableDto type for more information about the body parameter of the Create a new table endpoint.
At minimum, you must include "name", "tableScehma", and "type." "datasetUpdated", "hierarchyMetadata", and "uniqueTableConstraints" can be omitted. Below is sample Python request that uses the minimum body payload to create a new Data table called "Table Name" with the column "columnName" of type string (update values in italics).
import requests
import json
url = "https://h.<location>.wdesk.com/s/wdata/prep/api/v1/table"
payload = json.dumps({
"name": "Table Name",
"tableSchema": {
"columns": [
{
"name": "columnName",
"type": "string"
}
]
},
"type": "data"
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': '<valid token>'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)0Please sign in to leave a comment.
Comments
1 comment