Forum Discussion

Charline_74's avatar
Charline_74
Resolver I
3 years ago
Solved

Using a service account to use power bi api

Hello,

 

I am using a service account to run Power BI APIs.

 

When I use APIs like GET-PowerBI Workspace here no success it returns the workspace of which it is admin.


However, when I use it with Invoke-PowerBIRestMethod APIs I get this error message:

 

 Invoke-PowerBIRestMethod : Une ou plusieurs erreurs se sont produites.
Au caractère Ligne:26 : 1
+ Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/pip ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
    + FullyQualifiedErrorId : Une ou plusieurs erreurs se sont produites.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
 
Invoke-PowerBIRestMethod : Encountered errors when invoking the command: {
  "code": "PowerBINotAuthorizedException",
  "pbi.error": {
    "code": "PowerBINotAuthorizedException",
    "parameters": {},
    "details": [],
    "exceptionCulprit": 1
  }
}
Au caractère Ligne:26 : 1
+ Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/pip ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], Exception
    + FullyQualifiedErrorId : Encountered errors when invoking the command: {
  "code": "PowerBINotAuthorizedException",
  "pbi.error": {
    "code": "PowerBINotAuthorizedException",
    "parameters": {},
    "details": [],
    "exceptionCulprit": 1
  }
},Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod

 


For info the service account has a PowerBI PRO license.

 

Does anyone have a solution?

 

Thanks in advance, 

 

Charline

 

  • Hello,

    My problem is solved, it was just a right problem

    Thank you lbendlin and Anonymous  for your answers 🙂

3 Replies

  • The Power BI REST API documentation lists for every call if it can be made from a service principal.  Which calls are you attempting?

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI Charline_74,

    Can you please share some more detail about your scripts and credentials/permission settings? They will help us clarify your scenario and test to troubleshoot.

    Power BI REST APIs for embedded analytics and automation - Power BI REST API | Microsoft Learn

    In addition, what type of credentials are you used? Power bi account or service principal?

    If you mean service principal, they seem not able to be used as global variables and you need to re-input these credentials before API usages.

    Regards,
    Xiaoxin Sheng

  • Hello,

    My problem is solved, it was just a right problem

    Thank you lbendlin and Anonymous  for your answers 🙂