Forum Discussion
Power BI API Dataflow Import Operation
- 7 years ago
import is a bit trickey to get right
here is a sample:
POST https://api.powerbi.com/v1.0/myorg/groups/{groupId}/imports?datasetDisplayName=model.json HTTP/1.1
accept: application/json, text/plain, */*
cache-control: no-cache
Authorization: Bearer eyJ0eXAiOi...nQ
User-Agent: PostmanRuntime/7.3.0
accept-encoding: gzip, deflate
content-type: multipart/form-data; boundary=--------------------------613655670645709167014348
content-length: ...
Connection: close
< BODY>
----------------------------613655670645709167014348
Content-Disposition: form-data; name=""; filename="model.json"
Content-Type: application/json
{
"name": "my model",
"version": "1.0",
...
}
----------------------------613655670645709167014348--
Hi Anonymous, amos_ortal
I am able to create dataflow using import API in postman tool. In which, I manually fetched authorization token from the browser dev tools.
Now I need to do it through powershell script.
Could you please tell me how did you get Authorization token in your code?
I am basically trying to create a powershell script which asks for certain input parameters and then execute post API to create dataflow.
Thanks.
- imrannz7 years agoNew Member
Hi,
Did you manage to find a solution for this. I am wanting to do exactly what you are looking at but have been un-successful.
Thanks
- V557 years agoHelper I
Hi, It worked for me. I tried in PostMan.
URL - Select POST.
https://api.powerbi.com/v1.0/myorg/groups/<groupid>/imports?datasetDisplayName=model.json
Header:
Authorization - Bearer ... (I fetched it from browser while accessing powerBI)
Accept - application/json, text/plain, */*
Content-Type - multipart/form-data
Body:
Choose form-data and select choose Files button and import your json. While importing, make sure the json has different dataflow name. If existing name is given, it will return error. Thanks.
- Anonymous7 years agoNot applicable
To be able to fully incorporate a dataflow DTAP environment, moving dataflow model.json code definitions from development/test to acceptation and production workspaces "automatically" is a must have. Right now we have 3 dataflows loaded with 120 entities with lots of Power Query transforms, using Power Query parameters we can eventually dynamically switch input datasource to D/T/A/P Servers and databases. (in our case, SQL Servers/DB's).
I believe in the near future there should also be an "Import dataflow" UI configuration possible, besides the API's.
V55 Still couldn't get the POSTMAN setup to work, perhaps you could eleborate on this if you have time?Should be nice to developt a Powershell and incorporate it in our Azure Devops cycle, so we only develop a dataflow once, and deploy it entire (D)TAP environment.
Conceptually, something like this, I am no programmer (still need to complete HEADERS, BODY and parse online storage of model.json file ):
$headers = Get-PowerBIAccessToken
$ws_dev = "put your DT workspace GUID string"
$ws_uat = "put your UAT workspace GUID string"
$ws_prod = "put your PROD workspace GUID string"
$df_dev = "put your dataflow id you want to move"
Invoke-RestMethod -Headers $headers -Uri 'https://api.powerbi.com/v1.0/myorg/groups/" + $ws_dev + "/dataflows/ "+ $df_dev" Invoke-RestMethod -Headers $headers -Uri 'https://api.powerbi.com/v1.0/myorg/groups/" + $ws_uat + "/imports?datasetDisplayName=yourdataflowmodel.json