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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
trpeel
Frequent Visitor

Operation returned an invalid status code 'Forbidden'"

Hello. We are getting the following error while executing the GenerateTokenAsync(): "Operation returned an invalid status code 'Forbidden'".  

 

We've been testing Power BI Embedded for weeks but it suddenly stopped working. I've searched the forums and two of the responses deal with running out of free token requests. I've attempted to discover how many token requests I have remaining but haven't been able to get that to work, either. 

 

Any help would be appreciated. 

 

Thanks

Tye

1 ACCEPTED SOLUTION

Hi @trpeel 

 

Embed trial tokens are expected to be used during evaluation/development phase of embedded solutions. 

I'm not familiar with pricing and business side of things, but I do know that when moving to production customers are expected to use dedicated capacity to host their reports and datasets. See here: https://docs.microsoft.com/en-us/power-bi/developer/embedded/move-to-production

 

I hope that helps.

 

 

View solution in original post

3 REPLIES 3
AmosHersch
Microsoft Employee
Microsoft Employee

@trpeel  this API might help to see number of remaining tokens 

https://docs.microsoft.com/en-us/rest/api/power-bi/available-features/get-available-features

 

You can try to capture the entire response message with the 'Forbidden', sometimes the message body has more details for the error reason

Thanks Amos. I was able to figure out that I have 0 remaining tokens using the PowerShell script to query Power BI.

 

So, my question now is, since I have a VS Pro license and have activated my $50 azure credits each month, how do I use that to get more tokens? I thought the answer was to create a Power BI Embedded application in the Azure Portal, but that didn't help.

 

Here's the full response from Power BI:

 

XHRGEThttp://localhost:3000/api/Home/GetReport?workspaceId=...&reportId=...
[HTTP/1.1 500 Internal Server Error 6849ms]

1 Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'Forbidden'
2   at Microsoft.PowerBI.Api.ReportsOperations.GenerateTokenInGroupWithHttpMessagesAsync(Guid groupId, Guid reportId, GenerateTokenRequest requestParameters, Dictionary`2 customHeaders, CancellationToken cancellationToken)
3   at Microsoft.PowerBI.Api.ReportsOperationsExtensions.GenerateTokenAsync(IReportsOperations operations, Guid groupId, Guid reportId, GenerateTokenRequest requestParameters, CancellationToken cancellationToken)
4   at QueryService.Services.PowerBiServiceApi.GetReport(Guid WorkspaceId, Guid ReportId) in C:\Source\xxx\Modules\yyy\QueryService\QueryService\Services\PowerBiServiceApi.cs:line 61
5   at QueryService.Controllers.HomeController.GetReport(String workspaceId, String reportId) in C:\Source\xxx\Modules\yyy\QueryService\QueryService\Controllers\HomeController.cs:line 178
6   at lambda_method9722(Closure , Object )
7   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
8   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
9   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
10   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
11   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
12   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
13   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
14   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
15   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
16   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
17   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
18   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
19   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
20   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
21   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
22
23 HEADERS
24 =======
25 Accept: */*
26 Accept-Encoding: gzip, deflate, br
27 Accept-Language: en-US,en;q=0.5
28 Connection: close
29 Content-Type: application/json
30 Cookie: .AspNetCore.Cookies=CfDJ8I...
31 Host: localhost:44340
32 Referer: http://localhost:3000/xxx/yyy/zzz/?
33 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
34 x-forwarded-host: localhost:3000
35 x-forwarded-proto: http
36 x-forwarded-port: 3000
37 x-forwarded-for: 127.0.0.1
38 sec-fetch-site: same-origin
39 sec-fetch-mode: cors
40 sec-fetch-dest: empty
41 dnt: 1
42 access-control-allow-origin: *
43

 

Thanks for the help!

Hi @trpeel 

 

Embed trial tokens are expected to be used during evaluation/development phase of embedded solutions. 

I'm not familiar with pricing and business side of things, but I do know that when moving to production customers are expected to use dedicated capacity to host their reports and datasets. See here: https://docs.microsoft.com/en-us/power-bi/developer/embedded/move-to-production

 

I hope that helps.

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.