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.
I am using "Imports - Create Temporary Upload Location In Group" to import pbix to workspace having premium capacity.
$uri = "https://api.powerbi.com/v1.0/myorg/groups/XXXXXXX/imports/createTemporaryUploadLocation"
$tulResponse =Invoke-RestMethod -Uri $uri –Headers $auth_header –Method POST
$tulResponse return url , expiration ,and odata.context successfully .
$temp_path ="local path of Pbix "
$httpClient = New-Object System.Net.Http.Httpclient $httpClientHandler
$HttpClient.DefaultRequestHeaders.Add("x-ms-blob-type", "BlockBlob");
$packageFileStream = New-Object System.IO.FileStream @($temp_path, [System.IO.FileMode]::Open)
$contentDispositionHeaderValue = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue "form-data"
$contentDispositionHeaderValue.Name = "<< file name>>"
$contentDispositionHeaderValue.FileName = "<<filename.pbix>>"
$streamContent = New-Object System.Net.Http.StreamContent $packageFileStream
$streamContent.Headers.ContentDisposition = $contentDispositionHeaderValue
$content = New-Object System.Net.Http.MultipartFormDataContent
$content.Add($streamContent)
$response1 = $httpClient.PutAsync($tulResponse.url, $content).Result
response1 return s
----
Version : 1.1
Content : System.Net.Http.StreamContent
StatusCode : Created
ReasonPhrase : Created
Headers : {[x-ms-request-id, System.String[]], [x-ms-version, System.String[]], [x-ms-request-server-encrypted, System.String[]], [Date, System.String[]]...}
RequestMessage : Method: PUT, RequestUri: 'https://XXxxxxxxxxxx.blob.core.windows.net/xxxxxx/yyyyyyy/Import/zzzz?sv=2015-12-11&sr=b&sig=ccccccc...',
Version: 1.1, Content: System.Net.Http.MultipartFormDataContent, Headers:
{
x-ms-blob-type: BlockBlob
Content-Type: multipart/form-data; boundary="xxxxxxxxx"
Content-Length: 1091275
}
IsSuccessStatusCode : True
till then all are good
if($response1.IsSuccessStatusCode)
{
$bodypost = @{
'fileUrl' = $tulResponse.url
}
$uripost = "https://api.powerbi.com/v1.0/myorg/groups/xxxxx/imports?datasetDisplayName=<<filename>>&nameConflict..."
$respose2 =Invoke-RestMethod -Uri $uripost -Method POST -Body $bodypost -Headers $auth_header -ContentType 'multipart/form-data'
}
last line throw error
Invoke-RestMethod : {"error":{"code":"UnknownError","pbi.error":{"code":"UnknownError","parameters":{},"details":[],"exceptionCulprit":1}}}
Please help me out !! what I missed
Thanks in advance
Paritosh
Right now, I am working on this API. I can create temporary blob storage , but by using that Url I can't upload my greater than 1GB report PBIX file.
I don't know how to resolve this problem, Can you help me to sort out this problem?
Can you please help with me for this API?
Waiting for a solution
TIA
Anyone please share Request & Response headers/bodies of all three APIs
1. /imports/createTemporaryUploadLocation"
2. Upload pbix
3. /imports?datasetDisplayName= with body 'fileUrl' = $tulResponse.url
TIA
Hi @paritoshmishra ,
Unfortunately It's hard for me to know the problem if I don't go through your whole process, you have to know if the file exists in the destination directory before you make the call.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Liang
Pbix file store in my loacal system i.e $temp_path ="local path of Pbix "
My pbix size is 1.2 MB .Is it size of file matter ? Is tempoaryloactionupload is only works on file of size is greater then 1 GB ??
Please help me out
TIA
Did you find a solution?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
2 | |
1 | |
1 | |
1 |