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.
Dear Community,
I want to upload a locally created PBIX file to my pro account workspace. As I understand locally created files, cannot be imported to the workspace directly. It should be first go to one drive business and then to PBI server??!!
I am quite confused at this moment. I want to automate these tasks using REST APIs:
1) Upload the locally created dashboard / report to a workspace.
2) Publish the report / dashboard from a workspace to an APP.
3) Share the APP with some specific users.
So, the goal is to share a locally created report/ dashboard with some users.
At this moment I'm doing research on how with REST APIs of PBI that would be possible. I use at this moment Postman and I found resources quite ambiguis. any hint will be highly appreciated.
Solved! Go to Solution.
Hi, I am really appreciative of your reply. But I was looking for some REST API solution rather than Powershell.
Here is the solution:
groupId = "1c56b7fd-ea49-41db-8b96-xxx"
reportName = "yyy"
url = 'https://api.powerbi.com/v1.0/myorg/groups/' + groupId + '/imports?datasetDisplayName=' + reportName
headers = {
'Content-Type': 'multipart/form-data',
'authorization': 'Bearer ' + accessToken
}
file_location = './myreport.pbix'
# the second parameter is a tuple
# None means the filename is skipped (so the first parameter is the filename 🙂
# the second parameter is the file (in Nodejs shoubd be fs.createReadStream )
# and third parmeter is the format
files = {'value': (None, open(file_location, 'rb'), 'multipart/form-data')}
# we cannot send binary file to the server
# it needs to be converted to form-data using this function
mp_encoder = MultipartEncoder(fields=files)
# data parameters shows that is a dashboard / binary file
r = requests.post(
url=url,
data=mp_encoder, # The MultipartEncoder is posted as data, don't use files=...!
# The MultipartEncoder provides the content-type header with the boundary:
headers=headers
)
@mwegener
Hi @Anonymous,
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Hi, I am really appreciative of your reply. But I was looking for some REST API solution rather than Powershell.
Here is the solution:
groupId = "1c56b7fd-ea49-41db-8b96-xxx"
reportName = "yyy"
url = 'https://api.powerbi.com/v1.0/myorg/groups/' + groupId + '/imports?datasetDisplayName=' + reportName
headers = {
'Content-Type': 'multipart/form-data',
'authorization': 'Bearer ' + accessToken
}
file_location = './myreport.pbix'
# the second parameter is a tuple
# None means the filename is skipped (so the first parameter is the filename 🙂
# the second parameter is the file (in Nodejs shoubd be fs.createReadStream )
# and third parmeter is the format
files = {'value': (None, open(file_location, 'rb'), 'multipart/form-data')}
# we cannot send binary file to the server
# it needs to be converted to form-data using this function
mp_encoder = MultipartEncoder(fields=files)
# data parameters shows that is a dashboard / binary file
r = requests.post(
url=url,
data=mp_encoder, # The MultipartEncoder is posted as data, don't use files=...!
# The MultipartEncoder provides the content-type header with the boundary:
headers=headers
)
@mwegener
Hi @Anonymous ,
please mark your post as solution, this will also help others.
Please give Kudos for support.
Hi @Anonymous ,
look at this.
https://docs.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps
Regards,
Marcus
Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
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 |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |