0
votes

I got 401 unauthorized when trying to export a report from Power BI online by using the Power BI REST API.

My access token works fine with other API methods. I am also setting full API access in App registrations.

When I logged in by using the same account and use 'try', the access token provided in this test actually works. https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exportreport

Has anyone successfully used this method?

1
You are going to need to post the code you used for anyone to help you - GregGalloway

1 Answers

0
votes

You will need to create an Authentication app and provide the right privileges corresponding to the REST API you are loading from. For this particular API Microsoft suggests to provide Report.Read.All or Report.ReadWrite.All privileges.

You can achieve this directly by creating an authentication application from https://dev.powerbi.com/apps.

You will also need to make sure you grant the admin consent once your app is up and running.

Also, make sure the request you are creating is in the right format. If you match your request with the one specified here : https://docs.microsoft.com/en-us/rest/api/power-bi/reports/export report and test to check if it working with your parameters and login, you should be able to make it work with your code. Also test it with Postman to make sure you are entering the right configuration in the request and you know what you are requesting.

Once you have all this in place, you should not have any issues accessing the right data.