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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Charline_74
Resolver I
Resolver I

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

 

1 ACCEPTED SOLUTION
Charline_74
Resolver I
Resolver I

Hello,

My problem is solved, it was just a right problem

Thank you @lbendlin and @Anonymous  for your answers 🙂

View solution in original post

3 REPLIES 3
Charline_74
Resolver I
Resolver I

Hello,

My problem is solved, it was just a right problem

Thank you @lbendlin and @Anonymous  for your answers 🙂

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

lbendlin
Super User
Super User

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.