Forum Discussion
Fabric Create report API
- 7 months ago
Hello HeetParkhiya
Have you been able to run the Python script to create the payload and test it? I have provided the Python script in my earlier messages.
Here's the contents of my report.json, definition.pbir and .platform, modified slightly because I don't want to expose anything pertaining to my tenant.
report.json
{ "config": "{\"version\":\"5.68\",\"themeCollection\":{\"baseTheme\":{\"name\":\"CY25SU11\",\"version\":{\"visual\":\"2.4.0\",\"report\":\"3.0.0\",\"page\":\"2.3.0\"},\"type\":2}},\"activeSectionIndex\":0,\"defaultDrillFilterOtherVisuals\":true,\"settings\":{\"useNewFilterPaneExperience\":true,\"allowChangeFilterTypes\":true,\"useStylableVisualContainerHeader\":true,\"queryLimitOption\":6,\"exportDataMode\":1,\"useDefaultAggregateDisplayName\":true,\"useEnhancedTooltips\":true},\"objects\":{\"section\":[{\"properties\":{\"verticalAlignment\":{\"expr\":{\"Literal\":{\"Value\":\"'Top'\"}}}}}]}}", "layoutOptimization": 0, "resourcePackages": [ { "resourcePackage": { "disabled": false, "items": [ { "name": "CY25SU11", "path": "BaseThemes/CY25SU11.json", "type": 202 } ], "name": "SharedResources", "type": 2 } } ], "sections": [ { "config": "{}", "displayName": "Page 1", "displayOption": 1, "filters": "[]", "height": 720.00, "name": "7a9c9127a761dab1a1bb", "visualContainers": [], "width": 1280.00 } ] }definition.pbir
{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definitionProperties/2.0.0/schema.json", "version": "4.0", "datasetReference": { "byConnection": { "connectionString": "Data Source=\"powerbi://api.powerbi.com/v1.0/myorg/Fabric Workspace\";initial catalog=testCatalog;access mode=readonly;integrated security=ClaimsToken;semanticmodelid=838c6f17-025d-47cb-9dd5-11ce4b95db6d" } } }.platform
{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/gitIntegration/platformProperties/2.0.0/schema.json", "metadata": { "type": "Report", "displayName": "legacy_report" }, "config": { "version": "2.0", "logicalId": "8b4d6212-7372-4427-bec7-78855f7a4cab" } }
The error is coming from invalid file contents not how you wrapped the request. Your definition.pbir schema URL seems incomplete and must point to the full schema.json, otherwise validation fails. Your report.json is also too minimal; fabric requires at least stub properties like pages and config, not just themeCollection. Finally, the dataset reference must point to a real semantic model in the same workspace. Fix the schema URL, add the missing top-level sections to report.json, and verify the datasetID. Once those are valid UTF8 JSON strings and base64 encoded correctly, the REST create call succeeds.
Vinodh247 can you provide me the full schema for the definiation.pbir? because the docs provides the example of the only below provided json.
https://learn.microsoft.com/en-us/power-bi/developer/projects/projects-report?tabs=v2%2Cdesktop#definitionpbir
- Vinodh2477 months agoSuper User
There is no published full schema document listing every property for definition.pbir that you can download from microsoft; what exists is the JSON Schema endpoint URL (use VS Code for validation), and the effective expected content is extremely simple: essentially only these keys matter for REST deployment. What you need is this canonical structure (use this exact JSON with the correct schema URL and semantic model ID):
{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definitionProperties/2.0.0/schema.json", "version": "4.0", "datasetReference": { "byConnection": { "connectionString": "semanticmodelid=[SemanticModelId]" } } }replace [SemanticModelId] with your valid semantic model GUID
the schema expects:
$schema pointing to the published schema JSON (not truncated)
version (4.0 is typical for reports deployed from modern PBI Desktop/Fabric)
datasetReference.byConnection.connectionString with semanticmodelid=GUID
Other than those keys, the RESTAPI will reject anything extra or incomplete because it strictly validates against that schema. You cannot include additional keys outside what the schema defines for definition.pbir when creating via REST. If you need to explore every property the schema defines, you can paste the $schema URL into a code editor with JSON Schema support to see the full fields (this is the source of truth)
HTH!
- HeetParkhiya7 months agoFrequent Visitor
Hello, I have changed the definition.pbir and report.json, It is throwing the error " Content provider provided invalid package content stream"
I have changed or reverted the report.json to 1.0.0 schema version because many people are facing issues with the latest version.
report.json{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definition/report/1.0.0/schema.json", "layoutOptimization": "None", "themeCollection": { "baseTheme": { "name": "Default", "reportVersionAtImport": "1.0.0", "type": "SharedResources" } } }definition.pbir{ "$schema": "https://developer.microsoft.com/json-schemas/fabric/item/report/definitionProperties/2.0.0/schema.json", "version": "4.0", "datasetReference": { "byConnection": { "connectionString": "semanticmodelid=9e2b0971-7e50-4758-9241-310a603e7430" } } }