This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hallo Fabric Community,
{'status': 'Succeeded',
'createdTimeUtc': '2026-05-22T15:47:35.2651275',
'lastUpdatedTimeUtc': '2026-05-22T15:47:35.4583119',
'percentComplete': 100,
'error': None}`def getReportDefinition(workspaceId: str, reportId: str, headers: dict) -> dict:
"""
Fetch report definition, handling both 200 (sync) and 202 (async/polling).
Returns the parsed definition dict.
"""
_url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/reports/{reportId}/getDefinition"
_response = requests.post(_url, headers=headers)
# --- Synchronous response ---
if _response.status_code == 200:
return _response.json()
# --- Asynchronous response: poll until complete ---
if _response.status_code == 202:
_operationUrl = _response.headers.get("Location")
_retryAfter = int(_response.headers.get("Retry-After", 10))
if not _operationUrl:
raise ValueError("202 received but no Location header found.")
return _pollOperation(_operationUrl, _retryAfter, headers)
_response.raise_for_status()
def _pollOperation(operationUrl: str, retryAfter: int, headers: dict) -> dict:
"""
Poll a Fabric long-running operation until it succeeds or fails.
Returns the final result payload.
"""
MAX_POLL_ATTEMPTS = 20
for _attempt in range(1, MAX_POLL_ATTEMPTS + 1):
print(f" Polling attempt {_attempt}/{MAX_POLL_ATTEMPTS} — waiting {retryAfter}s ...")
time.sleep(retryAfter)
_pollResponse = requests.get(operationUrl, headers=headers)
_pollResponse.raise_for_status()
_pollJson = _pollResponse.json()
_status = _pollJson.get("status", "").lower()
if _status == "succeeded":
# The completed result is either inline or needs a separate GET
_resultUrl = _pollJson.get("createdTimeUtc") and _pollJson.get("percentComplete") and \
_pollJson.get("resourceLocation")
if _resultUrl:
# Some operations put the result at resourceLocation
_resultResponse = requests.get(_resultUrl, headers=headers)
_resultResponse.raise_for_status()
return _resultResponse.json()
# Result is embedded directly in the poll response
return _pollJson
if _status in ("failed", "cancelled"):
_error = _pollJson.get("error", {})
raise RuntimeError(
f"Operation {_status}: [{_error.get('errorCode')}] {_error.get('message')}"
)
# Still running — respect a new Retry-After if provided
retryAfter = int(_pollResponse.headers.get("Retry-After", retryAfter))
raise TimeoutError(f"Operation did not complete after {MAX_POLL_ATTEMPTS} polling attempts.")
def decodeReportJson(definition: dict) -> dict:
"""
Find report.json in definition parts, decode its InlineBase64 payload,
and return the parsed JSON content.
"""
_parts = definition.get("definition", {}).get("parts", [])
for _part in _parts:
if _part.get("path") == "report.json" and _part.get("payloadType") == "InlineBase64":
_decoded = base64.b64decode(_part["payload"]).decode("utf-8")
return json.loads(_decoded)
raise ValueError("report.json not found in definition parts.")
# --- Main ---
WORKSPACE_ID = workspaceId
REPORT_ID = reportId
_definition = getReportDefinition(WORKSPACE_ID, REPORT_ID, CONTRIBUTOR_SP_HEADERS_FABRIC)
Solved! Go to Solution.
@Kuladeep getDefinition request is a Long Running Operation in Fabric REST API and it's a 3-step process:
{
"definition": {
"parts": [
{
"path": "report.json",
"payload": "QmFzZTY0U3RyaW5n",
"payloadType": "InlineBase64"
},
{
"path": "definition.pbir",
"payload": "QW5vdGhlckJhc2U2NFN0cmluZw",
"payloadType": "InlineBase64"
},
{
"path": ".platform",
"payload": "ZG90UGxhdGZvcm1CYXNlNjRTdHJpbmc=",
"payloadType": "InlineBase64"
}
]
}
}
In your code above you do not extract the result URL correctly from the status response location header. You should extrat the result URL from the location header of the status response when percentComplete == "100". Do it like this:
_resultUrl = _response.headers.get("Location")
I tested in my environment and the process works correctly and returns the report definition in a form (obfuscated):
{
"definition": {
"format": "PBIR-Legacy",
"parts": [
{
"path": "definition.pbir",
"payload": "ewogIC...",
"payloadType": "InlineBase64"
},
{
"path": "StaticResources/SharedResources/BaseThemes/CYxxxxxx.json",
"payload": "ewogICJu...",
"payloadType": "InlineBase64"
},
{
"path": "report.json",
"payload": "ewogICJjb25maW...",
"payloadType": "InlineBase64"
},
{
"path": ".platform",
"payload": "ewo...",
"payloadType": "InlineBase64"
}
]
}
}
Hope you find this helpful. In such case give it kudos and accept as a solution to help other community members.
@Kuladeep getDefinition request is a Long Running Operation in Fabric REST API and it's a 3-step process:
{
"definition": {
"parts": [
{
"path": "report.json",
"payload": "QmFzZTY0U3RyaW5n",
"payloadType": "InlineBase64"
},
{
"path": "definition.pbir",
"payload": "QW5vdGhlckJhc2U2NFN0cmluZw",
"payloadType": "InlineBase64"
},
{
"path": ".platform",
"payload": "ZG90UGxhdGZvcm1CYXNlNjRTdHJpbmc=",
"payloadType": "InlineBase64"
}
]
}
}
In your code above you do not extract the result URL correctly from the status response location header. You should extrat the result URL from the location header of the status response when percentComplete == "100". Do it like this:
_resultUrl = _response.headers.get("Location")
I tested in my environment and the process works correctly and returns the report definition in a form (obfuscated):
{
"definition": {
"format": "PBIR-Legacy",
"parts": [
{
"path": "definition.pbir",
"payload": "ewogIC...",
"payloadType": "InlineBase64"
},
{
"path": "StaticResources/SharedResources/BaseThemes/CYxxxxxx.json",
"payload": "ewogICJu...",
"payloadType": "InlineBase64"
},
{
"path": "report.json",
"payload": "ewogICJjb25maW...",
"payloadType": "InlineBase64"
},
{
"path": ".platform",
"payload": "ewo...",
"payloadType": "InlineBase64"
}
]
}
}
Hope you find this helpful. In such case give it kudos and accept as a solution to help other community members.
Check out the April 2026 Fabric update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 18 | |
| 11 | |
| 9 | |
| 8 | |
| 6 |