403 forbidden when REST api call
I am calling "https://api.powerbi.com/v1.0/myorg/groups/{0}/reports/{1}/ExportTo" Api in my mvc application.
HttpWebRequest request = System.Net.HttpWebRequest.CreateHttp(string.Format("https://api.powerbi.com/v1.0/myorg/groups/{0}/reports/{1}/ExportTo", workspaceId,reportId1));
request.KeepAlive = true;
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("Authorization", String.Format("Bearer {0}", token));
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
string json = "{\"format\":\"PDF\"}";
streamWriter.Write(json);
}
var response = (HttpWebResponse)request.GetResponse();
Here i was getting access token like this,
string result = authContext.AcquireTokenAsync(resourceUriPowerBi, clientCredential).Result.AccessTok...
after this I got the error
{"error":{"code":"InvalidRequest","message":"Export report requires effective identity to be provided for the report's dataset"}}
then I write a code to get embed token by passing access level and identities i used at power bi Desktop to use RLS
string embedToken =
(await pbiClient.Reports.GenerateTokenInGroupAsync(workspaceId,
report.Id,
generateTokenRequestParameters)).Token;
Now I got the 403 forbidden error with no text.
Can anyone please help me to understand this why it is giving 403 error.
earlier i successfully called the refresh dataset api using access token got using client credential...
Tahnks in advance.
7 Comments
- v-qiuyu-msftCommunity Support
Hi Anonymous,
Please try the API with your account via Try it to see if the same issue occurs: https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofileingroup
Best Regards,
Qiuyun Yu - AnonymousNot applicable
Hi v-qiuyu-msft
Same response using Try it, Postman
Now, for reports which do not have row level security applied I am successfully able to get PDF by next api
Get File Of Export To File In Group.
But when I input reports to which Row level security applied from Power bi desktop giving this error
{"error":{"code":"InvalidRequest","message":"Export report requires effective identity to be provided for the report's dataset"}}
Here I thought I should use embed token with roles and identities, so I passed the embed token in Authorization header. But for this now I am getting 403 error.
I can't reach to conclusion whether I stick with access token or I should use embed token both are giving two different errors.
- v-qiuyu-msftCommunity Support
- Armand_TheronFrequent Visitor
I would like to know if you got this resolved ?
As I'm sitting with a simillar issue....
- taldermanFrequent Visitor
Like Armand_Theron, I would also like to know this was resolved.
- AnonymousNot applicable
Anonymous Did you ever solve this? We're having the exact same issue.
- ageetNew Member
Hi Anonymous Did you get the solution? we have same issue
{"error":{"code":"InvalidRequest","message":"Export report requires effective identity to be provided for the report's dataset"}}