I’m having the same error message.
We are using an angular2 SPA to interact with our REST API services. We have a report service that we would like to use to call the Power BI REST API service endpoints. We acquire an azure AD accessToken in our service and try and use that token for the PowerBI calls but keep getting the “The remote server returned an error: (403) Forbidden.” error. Our SPA is registered in Azure and we have given Power BI permissions to the application. I have an account in Power BI as well. Below is the code I am using to call the GetReports endpoint. The error is thrown when the GetResponse is called. Any suggestions would be greatly appeciated. Thanks.
var accessToken = Request.Headers.Authorization.Parameter; //defined in controller and passed to method below.
Uri baseAddress = new Uri(“https://api.powerbi.com/”); //defined above
public async Task<List<PbiReport>> GetPBIReports(string accessToken)
var powerBiApiUrl = baseAddress + “v1.0/myorg/reports”;
List<PbiReport> reports = new List<PbiReport>();
HttpWebRequest request = WebRequest.Create(powerBiApiUrl) as HttpWebRequest;
request.KeepAlive = true;
request.Method = “GET”;
request.ContentLength = 0;
request.ContentType = “application/json”;
request.Headers.Add(“Authorization”, $”Bearer “);
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
reports = JsonConvert.DeserializeObject<List<PbiReport>>(reader.ReadToEnd());