Forum Discussion

trpeel's avatar
trpeel
Frequent Visitor
4 years ago
Solved

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

3 Replies

    • trpeel's avatar
      trpeel
      Frequent Visitor

      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!