Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Power BI Export To File API gives 403 error

Hi All,

       I am using the following code to get the responseof delay time for Export file using the Export To File API, while executing this code with valid token but i am getting 403 as response code.Any one suggest a solution to overcome this issue.

 

Code

public static void getSiteDetails(String accessToken) throws IOException {

URL url = new URL ("https://api.powerbi.com/v1.0/myorg/reports/57e739a8-7af7-4778-a5a1-a91976e5c7d8/ExportTo");

HttpURLConnection con = (HttpURLConnection)url.openConnection();

con.setRequestMethod("POST");

con.setRequestProperty("Content-Type", "application/json");

con.setRequestProperty("Accept", "application/json");

con.setRequestProperty("Authorization", "Bearer " + accessToken);


con.setDoOutput(true);

String jsonInputString = "{\"format\":\"PDF\" }";

try(OutputStream os = con.getOutputStream()) {

 byte[] input = jsonInputString.getBytes("utf-8");

 os.write(input, 0, input.length);

}

try(BufferedReader br = new BufferedReader( new InputStreamReader(con.getInputStream(), "utf-8"))) {
 StringBuilder response = new StringBuilder();

 String responseLine = null;

 while ((responseLine = br.readLine()) != null) {

 response.append(responseLine.trim());

 }
 System.out.println(response);
 
 }
}

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous 

Please check whether you have access to this url.

I found some same issues like yours and I hope they could help you.

Blog1:HTTP 403 Forbidden error on API call

Blog2: 403 error thrown by power bi 

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

ibarrau
Super User
Super User

Hi. The problem might be in permission. 403 means forbiden. Even if you get a bearer token, that token can't complete the action because it doesn't have permission. An example of that is using a regular user to try an admin request. Please be sure to delegate the permissions in the registered app in Azure of Power Bi Service. It looks like that registered app is missing something for exporting.

Hope this helps,


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.