Forum Discussion
Exporting Paginated Report to excel, pdf, and json using Power BI API, with parameters passed
- 1 year ago
Hi Cherubelk
You can try troubleshooting the issue with--
Verify Parameter Names:
-
Open your paginated report in Power BI Report Builder.
-
Navigate to the Parameters pane.
-
Confirm the exact names of the parameters. Note that parameter names are case-sensitive and may include underscores or other characters.
Power BI -Export Paginated Report.
2.You can also Test with Known Values:Before deploying the solution, test the API call with known parameter values to ensure that the report exports as expected.
Hope this helps!
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You
-
-
Hi,
Considering that you've already reviewed the considerations and limitations of exporting paginated reports,, and still not able to export Paginated report-
1.Verify Parameter Names:
Ensure that the parameter names in your API request exactly match those defined in your paginated report. Parameter names are case-sensitive and must include any special characters or spaces.
2. Modify your parameters list in the API request to reflect the correct parameter names.
For example:
parameters = [
{"name": "Param_Report_Usage_Department", "value": "dep_name"},
{"name": "Param_Report_Usage_Report_Tester", "value": "N"},
]
Hope this helps!
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You!
Thank you for the help, but I already tried this and getting the same response.
To give more context this is what I am starting with:
access_token is from API that is already added as a member to a Premium Per User Workspace
export_url = f'https://api.powerbi.com/v1.0/myorg/groups/{group_id}/reports/{report_id}/ExportTo'
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {access_token}'
}
parameters = [
{"name": "Department", "value": "dep_name"}
]
export_data = {
"format": "XLSX",
"paginatedReportConfiguration": {
"parametersValues": parameters
}
}
My export function that will post export request, verify the request, then start the export.
def export_report():
response = requests.post(export_url, headers=headers, json=export_data)
if response.status_code == 202:
print('Export request accepted, waiting for completion...')
status_url = response.headers['Location']
while True:
status_response = requests.get(status_url, headers=headers)
if status_response.status_code == 200:
export_status = status_response.json()
for k, v in export_status.items():
print(f'{k}, {v}')
if export_status['status'] == 'Succeeded' and export_status['percentComplete'] == 100:
resource_location = export_status['resourceLocation']
file_response = requests.get(resource_location, headers=headers)
if file_response.status_code == 200:
with open(f'file_export_test{export_status["resourceFileExtension"]}', 'wb') as file:
file.write(file_response.content)
print('Report downloaded successfully!')
return
else:
print(f'Failed to download report: {file_response.status_code}')
return
# Export Fails
return
elif status_response.status_code == 202:
print('Export still in progress, waiting...')
time.sleep(10) # Wait for 10 seconds before checking again
else:
print(f'Failed to export report: {status_response.status_code}')
break
elif response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', 60)) # Default to 60 seconds if header is missing
print(f'Too many requests. Retrying after {retry_after} seconds...')
time.sleep(retry_after)
export_report() # Retry the export
else:
print(f'Failed to initiate export: {response.status_code}')
export_report()