Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I've got a report showing all applications and users having access to these applications. Some of the applications have multiple audiences with different users assigned.
When querying PBI Service with GetAppUsersAsAdmin API call I am receiving a list of users but there is no audience name. In result, it seems like these users have access to all reports in the application which is obviously not correct.
Is this possible to somehow get app audience and associated users? Thanks!
Well i managed to extract the audiance data via the API you have to set a timer after each rest call for 2.5 seconds to avoid the "Too Many requests error"
Code Below if anyone finds it usefull.
def GET_GROUPS(WorkspaceId):
Token = 'Bearer TOKEN HERE'
url = 'https://wabi-north-europe-l-primary-redirect.analysis.windows.net/metadata/appmodel/apps/'+WorkspaceId+'?requestDataType=7&access-control-allow-credentials=true';
headers = {"Accept":"application/json","Authorization":Token}
response = requests.get(url, headers = headers)
if response.status_code == 200:
return response.json()
else:
print("Error: ", response.status_code)
return response.json()
then you have to ge the Audience data.
def Clean_Result(df,Group):
#Create empty dataframe
df_empty = pd.DataFrame(columns=['Group','providerId','AppId','AppDisplayName','AudienceName','reportId','Users','AdName'],dtype='string')
#fill the empty dataframe with the values from the json file
try:
for i in range(len(df['appViewDetails'][0])):
for j in range(len(df['appViewDetails'][0][i]['reportIds'])):
for k in range(len(df['appViewDetails'][0][i]['contentProviderPermissions']['adUserMetadataList'])):
new_row = pd.DataFrame({"Group": [Group],
"providerId": [df['providerId'][0]]
,"AppId": [df['providerKey'][0]]
,"AppDisplayName": [df['displayText'][0]]
,"AudienceName":[df['appViewDetails'][0][i]['viewName']]
,"reportId":[df['appViewDetails'][0][i]['reportIds'][j]]
,"Users":[df['appViewDetails'][0][i]['contentProviderPermissions']['adUserMetadataList'][k]['userPrincipalName']]
,"AdName":[df['appViewDetails'][0][i]['contentProviderPermissions']['adUserMetadataList'][k]['displayName']]})
df_empty = df_empty.append(new_row)
dfs['vw_Audience_tmp'] = pandas_to_spark(df_empty)
return dfs['vw_Audience_tmp']
except:
print("No data for this group")
return dfs['vw_Audience_tmp']
stick this in a loop
with a timer
for each in dfs['vw_Groups'].collect():
time.sleep(2.5)
df = pd.json_normalize(GET_GROUPS(each['Id']))
df2 = Clean_Result(df,each['Id'])
if not df2.isEmpty():
df3 = df3.union(df2)
dfs['vw_Audience2'] = df3
dfs['vw_Audience2'].createOrReplaceTempView('vw_Audience2')
its not perfect but it does the job untill MS decide to get an official API
Hi there is an undocumented method but i cannot seem to get it working
if you make a get call to
https://wabi-north-europe-l-primary-redirect.analysis.windows.net/metadata/appmodel/apps/WoprkspaceO...?requestDataType=7&access-control-allow-credentials=true
but you need a bearer token and our bearer token that can access other PBI api does not work.
must be a permission issue .
but if you copy a bearer token from when you log in to power bi via f12 developer mode it does work.
i get a json response with the app and audiance name and members .
if anyone can help me how to get the correct bearer token i would appreciate this.
below is an extract
There is an open idea out there that is being investigated. https://community.fabric.microsoft.com/t5/Issues/GetAppUsersAsAdmin-API-Audience-Support/idi-p/28336...
sure but its been 3 years and no update from ms if this will be a available
Long standing gap. pretty much since the day audiences came out. We have complained loudly to Microsoft about it and all we got back is crickets. Make some noise on your side, raise a ticket, demand a bug fix.
If you have a Pro license you can open a Pro ticket at https://admin.powerplatform.microsoft.com/newsupportticket/powerbi
Otherwise you can raise an issue at https://community.fabric.microsoft.com/t5/Issues/idb-p/Issues .
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
2 |
User | Count |
---|---|
9 | |
7 | |
5 | |
4 | |
4 |