Post Datasets
Updated: March 14, 2017
The Post Datasets operation creates a new Dataset from a JSON schema definition and returns the Dataset ID and the properties of the dataset created.
Note To call this operation, an app token or key is required. To learn more, see Authenticating and authorizing with Power BI Embedded.
POST https://api.powerbi.com/v1.0/collections/{collectionName}/workspaces/{workspaceId}/datasets
Enable a default retention policy
POST https://api.powerbi.com/v1.0/collections/{collectionName}/workspaces/{workspaceId}/datasets?defaultRetentionPolicy={None | basicFIFO}
Uri parameter
| Name | Type | Description |
|---|---|---|
| collectionName (required) | String | When using a PBIX or Excel file, setting this parameter will override the default name of the dataset. |
| workspaceId (required) | String | If datasetDisplayName is provided, determines what to do if a Dataset with the same name exists. Otherwise, determines what to do if the Dataset is already imported. |
| Datasets (required) | Dataset | The entity to post. |
Query string parameter
| Name | Description | Values |
|---|---|---|
| defaultRetentionPolicy | Enables a default retention policy to automatically clean up old data while keeping a constant flow of new data going into your dashboard. To learn more about automatic retention policy, see Automatic retention policy for real-time data. | None or basicFIFO |
Header
Content-Type: application/json
Authorization: AppKey eyJ0eX ... FWSXfwtQ
Body schema
A Dataset has a name and collection of Table objects (tables). A Table has a name and collection of Column objects (columns). A Column has a name and data type. For a list of Power BI REST data types, see Supported data types.
A Dataset also has a defaultMode property, which determines whether the dataset is pushed, streamed, or both, with values of "Push", "Streaming", "PushStreaming", "AzureAS" and "AsOnPrem". The default value is "Push".
Body Schema for Push, Streaming and PushStreaming
{"name": "dataset_name",
"defaultMode" : "PushStreaming",
"tables":
[{"name": "", "columns":
[{ "name": "column_name1", "dataType": "data_type"},
{ "name": "column_name2", "dataType": "data_type"},
{ ... }
]
}
]
}
Body schema for Azure Analysis Services (AzureAS) and AsOnPrem
Body should have data sources in a datasources array. A data source has a name and connection string.
{"name": "dataset_name",
"defaultMode" : "AzureAS",
"tables":
[{"name": "", "columns":
[{ "name": "column_name1", "dataType": "data_type"},
{ "name": "column_name2", "dataType": "data_type"},
{ ... }
]
}
],
"datasources":
[{"name":"datasource1","connectionstring":"connection string"}]
}
Body example
A SalesMarketing Dataset with a Product Table schema (tables). The product Table has columns that describe a product.
{"name": "SalesMarketing","tables":
[{"name": "Product", "columns":
[{ "name": "ProductID", "dataType": "Int64"},
{ "name": "Name", "dataType": "string"},
{ "name": "Category", "dataType": "string"},
{ "name": "IsCompete", "dataType": "bool"},
{ "name": "ManufacturedOn", "dataType": "DateTime"}
]
}
]
}
Status code
| Code | Description |
|---|---|
| 201 | Created. The request was fulfilled and a new Dataset was created. |
| 202 | Accepted. The request was accepted and dataset creation is in progress. |
| 400 | Bad request. |
| 403 | Not authorized. |
Location header
Created location header
A location header is returned and is used to see the created dataset details. By accessing the location, the user will get a dataset object.
Example: https://api.powerbi.com/v1.0/myorg/datasets('075de301-cfff-4808-a1a2-4ea749796695')
Accepted location header
A location header is returned and is used for pulling to check the creation status. By accessing the location, the user will get an imported package object.
Example: https://api.powerbi.com/v1.0/myorg/imports/51e47fc5-48fd-4826-89f0-021bd3a80abd
Content-Type
application/json
Body schema
A Create Dataset response has the following schema:
{
"@odata.context":"https://api.powerbi.com/v1.0/myorg/$metadata#datasets/$entity",
"id":"{dataset_id}",
"name":"{name}",
"defaultRetentionPolicy":"{None | basicFIFO}"
}
Body example
The following is an example of a SalesMarketing Dataset JSON response with defaultRetentionPolicy set to basicFIFO. The Retention Policy automatically cleans up old data while keeping a constant flow of new data going into your dashboard.
{
"@odata.context":"https://api.powerbi.com/v1.0/myorg/$metadata#datasets/$entity",
"id":"7c0b090e--b51-172874c749e0",
"name":"SalesMarketing",
"defaultRetentionPolicy":"basicFIFO"
}
Azure Analysis Services
Create dataset in Power BI Saas Service
More questions? Try the Power BI Community