Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
Is there a way I could convert a pbix file to pbit through code?
Say I have hundreds or thousands of files. I would like to extract the json (DataModelSchema) file of each pbix which I have to do for all files manually and could only be done through manual export or using save as for every single file.
1- save a pbix file as pbit (main problem to automate)
2-unzip the file and extract the json (feasible in python)
Thanks.
Solved! Go to Solution.
Hi @Shiroyasha1 ,
Thank you for reaching out and sharing the links in your conformation query. Unfortunately, I am unable to access external links. However, I do have detailed information regarding the topic you're asking about.
As discussed, the Power BI API doesn't support PBIX to PBIT conversion. You could try Power Automate for exporting reports, but it only works with Power BI Service-hosted reports, not local PBIX files.
You’ve used pyautogui to automate the "Save As" process for exporting PBIX to PBIT, which works but isn’t ideal for large batches.
You mentioned that you can access the Power BI REST API but only see SSRS reports, not Power BI reports. This indicates that your current access may be pointing to the SSRS reports endpoint rather than Power BI reports.
The endpoint GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/Export exports Power BI report contents (e.g., PDF, PPTX), not the PBIX file. To work with Power BI reports, use the correct API endpoints for Power BI reports (not SSRS reports).
To list Power BI reports in your workspace, use:
GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports
This will return a list of reports (not SSRS) in the specified workspace.
The endpoint you found exports a Power BI report (not PBIX). After retrieving the report, use the export endpoint to trigger the export.
GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/Export
Ensure you're querying the correct workspace by using the right groupId. You may need to list your organization’s workspaces to confirm it. There’s no API to download PBIX files from the Power BI Service. The API only exports report contents (e.g., PDF, PPTX), not the PBIX file.
For more information refer to below link:
Reports - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Reports - Export Report In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Reports - Export To File - REST API (Power BI Power BI REST APIs) | Microsoft Learn
I hope this helps! If you have any more questions or need further assistance, feel free to let me know.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thankyou
Hi @Shiroyasha1 ,
Thanks for reaching out to the Microsoft fabric community forum.
For your question, here are my answers:
Q1: save a pbix file as pbit (main problem to automate):
For your reference go through it:
https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Automate-the-process-of-exporting-Power-...
Q2: unzip the file and extract the json (feasible in python).
Once the PBIX files are converted to PBIT files, the next task is to extract the DataModelSchema (JSON) from the PBIT file, which is essentially a ZIP archive.
Follow below link for your reference:
zipfile — Work with ZIP archives — Python 3.13.1 documentation
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best regards,
Pranay
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Pranay, thank you for reaching out.
Please mind my knowledge gaps, as I am fairly new to this.
Anyways, for Q2 it was smoothly done as for the 1st part, my current solution was to use pyautogui and simulate the exact keyboard steps I need to export a pbix file as pbit.
Could you elaborate more about the REST API? This could be the solution I need as we are using PowerBI Development Server for both PBIX and SSRS reports, which I'm assuming is the same thing as PowerBI Service. I did connect to https://pbi.#######.com/reports/api/v2.0/Reports. (#### being my org internal name instead). This lists all the SSRS reports and does not include the PBI reports. Is there another API for specifically PBI reports? I found the following from https://learn.microsoft.com/en-us/rest/api/power-bi/reports/export-report -- GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/Export Is there a way I could utilize this?
The end goal is obtaining the json file (most likely from a .pbit file). Appreciate your help.
thanks again,
Ali
Hi @Shiroyasha1 ,
Thank you for reaching out and sharing the links in your conformation query. Unfortunately, I am unable to access external links. However, I do have detailed information regarding the topic you're asking about.
As discussed, the Power BI API doesn't support PBIX to PBIT conversion. You could try Power Automate for exporting reports, but it only works with Power BI Service-hosted reports, not local PBIX files.
You’ve used pyautogui to automate the "Save As" process for exporting PBIX to PBIT, which works but isn’t ideal for large batches.
You mentioned that you can access the Power BI REST API but only see SSRS reports, not Power BI reports. This indicates that your current access may be pointing to the SSRS reports endpoint rather than Power BI reports.
The endpoint GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/Export exports Power BI report contents (e.g., PDF, PPTX), not the PBIX file. To work with Power BI reports, use the correct API endpoints for Power BI reports (not SSRS reports).
To list Power BI reports in your workspace, use:
GET https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports
This will return a list of reports (not SSRS) in the specified workspace.
The endpoint you found exports a Power BI report (not PBIX). After retrieving the report, use the export endpoint to trigger the export.
GET https://api.powerbi.com/v1.0/myorg/reports/{reportId}/Export
Ensure you're querying the correct workspace by using the right groupId. You may need to list your organization’s workspaces to confirm it. There’s no API to download PBIX files from the Power BI Service. The API only exports report contents (e.g., PDF, PPTX), not the PBIX file.
For more information refer to below link:
Reports - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Reports - Export Report In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Reports - Export To File - REST API (Power BI Power BI REST APIs) | Microsoft Learn
I hope this helps! If you have any more questions or need further assistance, feel free to let me know.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thankyou
Hi @Shiroyasha1 ,
I wanted to follow up as we haven't received a response from you regarding our previous message. I hope your issue has been resolved.
If my answer resolved your query, please mark it as "Accepted Answer" and provide "Kudos" if you found it helpful.
Should you need any further assistance, please do not hesitate to reach out.
Thank you for being a valued member of the Microsoft Fabric Community Forum.
Best regards,
Pranay
Hi @Shiroyasha1,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
User | Count |
---|---|
73 | |
72 | |
39 | |
25 | |
23 |
User | Count |
---|---|
96 | |
93 | |
51 | |
43 | |
42 |