Create Import
Updated: July 21, 2017
The Create Import operation creates content from either a PBIX, Excel, package file or file path in OneDrive Pro, and returns the ID of the Import created. This allows you to take a package of content, such as a PBIX or Excel file, and import it into a Power BI workspace. The Imports API splits the PBIX package into its individual parts including datasets and reports. It will then provide a metadata link between the actual import operation and the objects that were created from it.
Note The operation has the same behavior as if you imported an Excel file through the connect screen in Power BI.
Required scope: Dataset.ReadWrite.All
POST https://api.powerbi.com/v1.0/myorg/imports
Groups
Groups are a collection of unified Azure Active Directory groups that the user is a member of and is available in the Power BI service. These are referred to as app workspaces within the Power BI service. To learn how to create a group, see Create an app workspace.
POST https://api.powerbi.com/v1.0/myorg/groups/{group_id}/imports
Uri parameter
| Name | Description | Data Type |
|---|---|---|
| group_id | Guid of the Group to use. You can get the group id from the Get Groups operation. Groups are referred to as app workspaces within the Power BI service. | String |
Query string parameters
| Name | Type | Description | Values |
|---|---|---|---|
| datasetDisplayName | String | When using a PBIX or Excel file, setting this parameter will override the default name of the dataset. | A Dataset name. |
| nameConflict | 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. | - Ignore (default) - Abort - Overwrite |
| PreferClientRouting | String | Use this parameter to avoid the request redirecting between clusters and to avoid timeout errors. | - true - false (default) |
Header
Content-Type: multipart/form-data
Authorization: Bearer eyJ0eX ... FWSXfwtQ
Request Body
- If importing from a file, the body will contain a PBIX or Excel file encoded as form data.
- If importing from OneDrive Pro, the body will contain JSON properties that include file path and connection type.
- Connection type: import file data as dataset or connect Excel workbook as report. Values: import, connect. Optional parameter. Default is import.
- File path can be absolute or relative to the URL of the file.
- The filePath will use the OneDrive file API path.
File path example:
filePath = shared%20with%20everyone/Denver%20Data.xlsx
Body schema
An Import has a filePath and a connectionType.
To import data from your file:
{
"filePath": "shared with everyone/FileName.xlsx",
"connectionType": "import"
}
To connect your Excel workbook as a report:
{
"filePath": "shared with everyone/FileName.xlsx",
"connectionType": "connect"
}
Response Headers
- Location header that points to the location of the import status information.
- Retry-After header indicating the number of seconds the client should wait to make the next request
Success status code
| Code | Description |
|---|---|
| 201 | Created. The request was fulfilled and a new Import was created. |
| 202 | Accepted if the import is still in progress. |
| 307 | Message should be forwarded. The location to forward is in the Response Location Header. |
Error status code
| Code | Description |
|---|---|
| 400 | Bad request. Examples: corrupted file, invalid name conflict, etc… |
| 409 | Imported file exists with the same connectionType. |
Content-Type
application/json
Body schema
A Create Import response has the following schema:
{"id": "{import_guid}"}