Click here to Skip to main content
15,798,592 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Failed to create report. Error: b'{\r\n  "error":{\r\n    "code":"","message":"No HTTP resource was found that matches the request URI \'\'."\r\n  }\r\n}'

this is the error I'm getting

What I have tried:

import requests
import json

# Set your Power BI REST API endpoint URLs
base_url = ""
reports_url = f"{base_url}/groups/{group_id}/reports"

# Set your authentication token
access_token = "YOUR_ACCESS_TOKEN"

# Set the group ID where the report will be created
group_id = "YOUR_GROUP_ID"

# Create a report definition
report_definition = {
    "name": "My Report",
    "datasetId": "EXISTING_DATASET_ID"

# Create the report in the group
def create_report():
    create_report_url = reports_url
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Content-Type": "application/json"
    payload = {
        "name": report_definition["name"],
        "datasetId": report_definition["datasetId"]
    response =, headers=headers, json=payload)
    if response.status_code == 201:
        report_id = response.json()["id"]
        print("Report created successfully. ID:", report_id)
        return report_id
        print("Failed to create report. Error:", response.content)
        return None

# Run the function to create the report

This is what i have tried
Updated 14-Jun-23 2:49am
Richard MacCutchan 14-Jun-23 7:58am    
You need to check that the URI you are using is the correct one for the API.

1 solution

You have an invalid character - 'f'
headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json"

change to:
headers = {
    "Authorization": "Bearer {access_token}",
    "Content-Type": "application/json"

The error message is the clue:
No HTTP resource was found that matches the request URI

This is saying that the data does not exist at that address. Check that the URL is correct. Also, see if there is a response code, that can also indicate what the issue is - could be that there is an authorization issue.
Share this answer
Richard MacCutchan 14-Jun-23 7:56am    
No, that is the correct way to specify inline formatting in Python.
Graeme_Grant 14-Jun-23 8:00am    
Ah, wasn't sure which language he was using. It looked out of place.
Richard MacCutchan 14-Jun-23 8:19am    
Didn't they send you one of the CodeProject Crystal Balls? :)
Graeme_Grant 14-Jun-23 8:24am    
ROFL ... I missed out last Xmas, maybe this year. Python is on my list of languages to learn, just have to find the time...
Dave Kreskowiak 14-Jun-23 9:35am    
Mine was arrived but shattered during shipping. Chris has yet to send me another one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900