Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hello everybody,
I am trying to programatically upload an Excel file (could also be a JSON file) to a workspace using the API but I can't seem to make it quite work.
I am using the endpoint as specified at https://docs.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group where the phrasing leads me to believe it should be possible to import Excel files this way.
Sample C# code used :
public bool ImportExcelFileToWorkspace(string filePath, string filename, string displayName)
{
var req = new HttpRequestMessage(HttpMethod.Post, $"https://api.powerbi.com/v1.0/myorg/groups/{Context.GroupId}/imports?datasetDisplayName={displayName}");
var content = new MultipartFormDataContent();
Stream fileStream = File.OpenRead(filePath);
content.Add(new StreamContent(fileStream), displayName, filename);
req.Content = content;
Credentials.ProcessHttpRequestAsync(req, CancellationToken.None);
var message = Client.HttpClient.Send(req);
return message.IsSuccessStatusCode;
}
I am using a class with a Credentials fields that uses the .NET API Connector and auth is fine.
Both the filename and displayname variables feature the file extension.
Using this method, I am being return an error 400 Bad Request with detail "ExcelWorkbookHasNoDataException" which is false.
Has anybody successfully used this endpoint like I am intending ? Any insight as to what I might be doing wrong ?
Thank you all in advance !
Solved! Go to Solution.
Hi @risDS ,
Quick solution
You need create a data model in your excel when you want to upload excel to power bi serive.
For more details, you can refer this link.
Error: We couldn't find any data in your Excel workbook - Power BI | Microsoft Docs
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @risDS ,
Quick solution
You need create a data model in your excel when you want to upload excel to power bi serive.
For more details, you can refer this link.
Error: We couldn't find any data in your Excel workbook - Power BI | Microsoft Docs
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |