Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rbroida
Helper I
Helper I

Imports.Postimportingroup() in .NET SDK returns 400 Bad Request

Using the .NET SDK, I want to programmatically import a dataset, which is defined in a .PBIX file stored in OneDrive for Business, into an app workspace. The method PowerBIClient.Imports.PostImportInGroupAsync() is supposed to accomplish this. However, I get inscrutable 400 Bad Request errors whenever I call it.

 

Microsoft doesn't seem to have any online documentation of this .NET SDK method. (There doesn't seem to be complete reference documentation to the .NET SDK, period.) There is documentation for the underlying REST API here:

 

https://docs.microsoft.com/en-us/rest/api/power-bi/imports/postimportingroup#importconflicthandlermo...

 

What I don't see is any explanation of what the "ImportInfo" (sent as message body in the REST API) should contain. It has three properties, all strings: FilePath, FileUrl, and ConnectionType. I believe ConnectionType is supposed to be set to "import", but I don't know what the proper for is for FilePath or FileUrl, and I have found no examples.

 

Could someone please explain, preferably with an example, how to call this SDK method successrfully?

Code in C# is essentially this:

 

 

9 REPLIES 9
andrask
New Member

Having the same issue here. Attaching SDK C# code.

 

var importUrl = $"https://api.powerbi.com/v1.0/myorg/groups/{targetWorkspaceId}/imports?datasetDisplayName={reportName...";
var importRequest = new { fileUrl = recievedUploadUrl };
var importResponse = await httpClient.PostAsync(importUrl, new StringContent(JsonConvert.SerializeObject(importRequest), Encoding.UTF8, "application/json"));

@andrask - did you find a fix for this? We had stuff working a couple of months back and now get the same error.

yaniv-a
New Member

I have the same problem here for large files with premium capacity.

BadRequest is recieved when using either rest api or .net sdk v2.

The error happens after the pbix has been uploaded successfully to the temp blob location.

The http response is empty so there isn't any meaningful information to troubleshoot.

.pbix files <1GB are imported without issues.

 

I hope someone from Power BI team can look into it ASAP.

Can you please share your .Net sdk code to. Upload pbix?
I am facing this error when uploading a 10 mb pbix. I am on a pro account.
Help will be much appreciated as I am stuck on this for quite some time now.
integrationsupp
Frequent Visitor

Do we have an update or example for this ??

Dan2
Helper I
Helper I

Would like an answer to this as well

I have the same problem with this api.

I try to call the api from Sdk V2 "PostImportWithFileAsyncInGroup" and also create a post to this url "https://api.powerbi.com/v1.0/myorg/groups/{groupID}/imports?datasetDisplayName={name}": the response is always BadRequest.

 

How can I fix?

 

Thanks

 

I'm also getting the Bad Request response - pretty amazing that more than a year after the question was first asked the question is still unanswered and the documentation is still woefully inadequate. 

 

What a waste of time for developers to reverse-engineer APIs that should've been documented in teh first place.

jbrandt
Advocate I
Advocate I

Looking for this info as well, did you ever find any examples?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors