Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Importing a large pbix via Post Import In Group

I am struggling with the rest api and i'm hoping i'm just missing something.  I am able to post to the import endpoint and publish a file using the .net client

var upload2 = await client.Imports.PostImportWithFileAsyncInGroup(groupid, fs, "test");

 

works great.  Now when i try and use the temporary file location for a large file i keep getting 400 bad request errors.

 

            var temp = await client.Imports.CreateTemporaryUploadLocationInGroupAsync(groupid);


            var fs = new FileStream("xxxxx.pbix", FileMode.Open,FileAccess.Read);
            fs.Position = 0;
            await saveBlob(temp.Url, fs);
            var importdetails = new Microsoft.PowerBI.Api.V2.Models.ImportInfo
            {
                //ConnectionType = ConnectionType.Import
                FileUrl = temp.Url,
                //FilePath = string.Empty
            };

            var upload = await client.Imports.PostImportInGroupAsync(groupid, "testpositions", importdetails);

The create of the tempfile works and the upload of that file is successful. Here is the raw request

 

POST https://api.powerbi.com/v1.0/myorg/groups/[groupid removed from sampl]/imports?datasetDisplayName=testpositions HTTP/1.1
Authorization: Bearer [removed from sample]
User-Agent: FxVersion/4.6.27414.05 OSName/Windows OSVersion/Microsoft.Windows.10.0.15063. Microsoft.PowerBI.Api.V2.PowerBIClient/3.4.0.19204
Content-Type: application/json; charset=utf-8
Content-Length: 315
Host: api.powerbi.com

{
  "fileUrl": "https://wabincuspbiv2p1.blob.core.windows.net/d331431b-899c-4666-8094-e82e6bfc3964/a7634353-a598-4420-b125-6b55801d2baa/Import/00a33942-a321-476c-8718-c27a0b2d8f02?sv=2015-04-05&sr=b&sig=pF8MdpeBu3mhyi8LPSQlNP6V63iUgMpaKFXVbEoNsiY%3D&st=2019-08-15T16%3A22%3A19Z&se=2019-08-16T16%3A27%3A19Z&sp=w"
}

I've tried ever combination of parameters in the post but always get back

 

HTTP/1.1 400 Bad Request
Content-Length: 0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: deny
X-Content-Type-Options: nosniff
Access-Control-Expose-Headers: RequestId
RequestId: 54c996a6-217b-40ef-ae39-da47e450a04b
Date: Thu, 15 Aug 2019 16:27:19 GMT

Does anyone have a sample successful post call to imports using the fileURL parameter?

  • Anonymous's avatar
    Anonymous
    7 years ago

    Turns out the api handles large files automatically.  Just need to use the 

    .PostImportWithFileAsyncInGroup

    and it detects if the file is over 1gb.  Very nice 

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Turns out the api handles large files automatically.  Just need to use the 

    .PostImportWithFileAsyncInGroup

    and it detects if the file is over 1gb.  Very nice 

    • Anonymous's avatar
      Anonymous
      Not applicable

      i know this is old but im looking at this exact issue right now. so for files over a gig i can still just upload the raw file using PostImportWithFileInGroup and dont have to upload to a temporary location first?