cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
haiyangl104
Frequent Visitor

Https 401 Unauthorized Post Request for Refreshing Power BI datasets using REST API via Python

I experience the following error when trying to refresh my Power BI dataset in a particular workspace via Python:

 

haiyangl104_0-1622658846628.png

 

I've followed this guide online and registered Power BI as "Native App" in Azure Active Directory>App Registrations:

Automate Your Power BI Dataset Refresh with Python - Pivotal BI

 

Under "Azure Active Directory>App Registrations", our Azure Admin provisioned the following API permissions from the guide:

 

haiyangl104_1-1622660756509.png

 

In Power BI Web Services, I've configured the Data Source credentials correctly:

 

haiyangl104_2-1622660866858.png

 

Despite following all the steps exactly from the guide, refreshing the dataset via Power BI API post request does not work. Strangely, manually clicking refresh button on Power BI desktop and Power BI web services do work.

 

Any help is appreciated!

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @haiyangl104,

>>After digging deeper, I found out that my Power BI Pro licensed account is on the Gov Cloud, with address of

It sounds like you are working with GOV cloud.

Currently, we do not have permission to test with these types of resources. I'd like to suggest you open a support ticket to power bi team for further supports.

submit a support ticketsubmit a support ticket

Support | Microsoft Power BI

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

9 REPLIES 9
v-shex-msft
Community Support
Community Support

HI @haiyangl104,

I found you use the f format string in these steps, have you try to concatenate strings with delimiter or use static values to test and send requests?

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Yes, I've tried using static values in the refresh_url path but still no luck:

haiyangl104_0-1623082527471.png

 

Hi @haiyangl104,

If you test on the same variables on documents online testing(REST API document -> try it), did these API works?

I'd like to confirm if your credentials are available for the rest API usage. 

Datasets - Refresh Dataset In Group - REST API (Power BI Power BI REST APIs) | Microsoft Docs

Notice: 401 error seems related to request credentials.

401 Unauthorized - HTTP | MDN (mozilla.org)

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

The tool you've posted is incredibly helpful! I found out the issue: My Azure account (john.doe@abc) and Power BI Pro licensed account (john.doe@xyz) have two different domain names. Because I'm sending HTTPS post request from my Azure account, the error code is saying that the account does not have Power BI Pro License. Do you have any suggestions for authorizing dataset refresh post request from a different Azure account? Our organization's IT department chose to de-couple our Power BI accounts and our Azure accounts, which is outside of my control.

Hi @haiyangl104,

So you mean your accounts are split into different parts and the current one which you used only has permission to operate power bi contents not has permission to operate these APIs?

If that is the case, you can consider using the azure b2b feature to share the permission to access these contents if it works for the rest API usages.

Distribute content to external guest users with Azure AD B2B - Power BI | Microsoft Docs

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

After digging deeper, I found out that my Power BI Pro licensed account is on the Gov Cloud, with address of "https://app.powerbigov.us/". I noticed that the Power BI REST API documentation only have "https://api.powerbi.com" which is for commercial users. I looked online for GCC version of API by switching to: "https://api.powerbigov.us"  but it gives me back the following error:

 

HTTPError: 403 Client Error: Forbidden for url: https://api.powerbigov.us/v1.0/myorg/groups

Hi @haiyangl104,

>>After digging deeper, I found out that my Power BI Pro licensed account is on the Gov Cloud, with address of

It sounds like you are working with GOV cloud.

Currently, we do not have permission to test with these types of resources. I'd like to suggest you open a support ticket to power bi team for further supports.

submit a support ticketsubmit a support ticket

Support | Microsoft Power BI

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

For some reason clicking on "Create support ticket" says I don't have a Power BI Pro License:

haiyangl104_0-1623782857664.png

 

But I do have a Pro license under Power BI Gov Cloud (app.powerbigov.us):

haiyangl104_1-1623783059773.png

 

Is there any other way to get around this problem?

Hi @haiyangl104m

I'd like to suggest you submit a ticket with your gov account with 'support ticket' or 'national cloud' mode.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors