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
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
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.