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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
tfanaswala
Frequent Visitor

Access Admin API via a Service Principal

I've created a service principal in Azure with the below permissions:

tfanaswala_0-1743089217873.png

This service principal has also been granted access to Fabric APIs, and to Admin APIs in the Fabric Admin console. Additionally, the service principal has been added as an admin for our tenant. I can access regular API endpoints, like Groups, as expected, but when I try to access the Get Activities endpoint in the Admin API, I get a 400 error with nothing in the body. The endpoint I am targetting is https://api.powerbi.com/v1.0/myorg/admin/activityevents.

 

What am I doing incorrectly when trying to access this API?

1 ACCEPTED SOLUTION
v-aatheeque
Community Support
Community Support

Hi @tfanaswala 


It sounds like you've set up everything correctly. Since you've got the right permissions and access, the issue is likely with the API request itself. Here are a few things you can check:

 

1. Check the Request URL:  
   The Get Activities API needs specific parameters like `startDateTime` and `endDateTime`. Make sure they’re in the correct format (ISO 8601) and within a 30-day range.  
   Example:   https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2024-03-01T00:00:00Z&endDateTi...

 

2. Verify Your Token:  
   Double-check that you’re using a valid Bearer token with the right scopes. The token should have permissions like `Dataset.Read.All` or `Tenant.Read.All`.  

 

3. Confirm Admin API Access:  
   Even though the permissions look good, the service principal needs to be explicitly allowed to use the Admin API.  
   Go to Power BI Admin Portal → Tenant Settings → Admin API Settings and make sure the option "Allow service principals to use read-only Admin APIs" is enabled.  

 

4. Try a Simple API Call:  
   You could test with PowerShell to rule out other issues. Here’s an example:  
   powershell
   Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2024-03-01T00:00:00Z&endDateTi...

 

5. Check Azure Logs:  
   If nothing works, check Azure AD logs for any failed sign-ins or authorization issues.  
   Go to Azure Active Directory → Monitoring → Sign-ins for more details.  



If this post was helpful, please consider marking Accept as solution to assist other members in finding it more easily.

If you continue to face issues, feel free to reach out to us for further assistance!

 

 

 

View solution in original post

4 REPLIES 4
v-sathmakuri
Community Support
Community Support

Hi @tfanaswala  ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thanks!!

v-aatheeque
Community Support
Community Support

Hi @tfanaswala 


It sounds like you've set up everything correctly. Since you've got the right permissions and access, the issue is likely with the API request itself. Here are a few things you can check:

 

1. Check the Request URL:  
   The Get Activities API needs specific parameters like `startDateTime` and `endDateTime`. Make sure they’re in the correct format (ISO 8601) and within a 30-day range.  
   Example:   https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2024-03-01T00:00:00Z&endDateTi...

 

2. Verify Your Token:  
   Double-check that you’re using a valid Bearer token with the right scopes. The token should have permissions like `Dataset.Read.All` or `Tenant.Read.All`.  

 

3. Confirm Admin API Access:  
   Even though the permissions look good, the service principal needs to be explicitly allowed to use the Admin API.  
   Go to Power BI Admin Portal → Tenant Settings → Admin API Settings and make sure the option "Allow service principals to use read-only Admin APIs" is enabled.  

 

4. Try a Simple API Call:  
   You could test with PowerShell to rule out other issues. Here’s an example:  
   powershell
   Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime=2024-03-01T00:00:00Z&endDateTi...

 

5. Check Azure Logs:  
   If nothing works, check Azure AD logs for any failed sign-ins or authorization issues.  
   Go to Azure Active Directory → Monitoring → Sign-ins for more details.  



If this post was helpful, please consider marking Accept as solution to assist other members in finding it more easily.

If you continue to face issues, feel free to reach out to us for further assistance!

 

 

 

You were right that there was something wrong with the API call. I needed to wrap the dates in quotation marks, and I was going too far back in time when I was querying for events.

Deku
Community Champion
Community Champion

Are you sure the URL is correctly formed with start and end dates in the correct format. Can you share an example URL 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

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

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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