<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Empty &amp;quot;Roles&amp;quot; column ib  GetScanResult API Call when trying to find AD Groups in RLS P in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Empty-quot-Roles-quot-column-ib-GetScanResult-API-Call-when/m-p/4015087#M53774</link>
    <description>&lt;P&gt;Hi&amp;nbsp; @Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your use of this Power BI admin API you will also encounter the specific 404 error status code "404, {"error":{"code": "ItemNotFound", "message": "Dataset abcde-12345-12345-abcde is not found."}}." At your convenience, can you verify that the account you generated and used the AAD token for has access to the dataset ID "abcde-12345-12345-abcde"? You can also consider using service principal authentication to execute this API, provided that you also meet the prerequisites of the API for service principals in the documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasets-as-admin" target="_blank"&gt;Admin - Datasets GetDatasetsAsAdmin - REST API (Power BI Power BI REST APIs) | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vyangliumsft_0-1719562843287.jpeg" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1123754i4114188E5AF1B4EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="vyangliumsft_0-1719562843287.jpeg" alt="vyangliumsft_0-1719562843287.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jun 2024 08:20:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-06-28T08:20:55Z</dc:date>
    <item>
      <title>Empty "Roles" column ib  GetScanResult API Call when trying to find AD Groups in RLS Power BI</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Empty-quot-Roles-quot-column-ib-GetScanResult-API-Call-when/m-p/4013003#M53749</link>
      <description>&lt;P&gt;My end goal is to find all RLS setting used in a Power BI Dataset and to see which AD groups have been connected to these roles. To do this, I have followed the &lt;A title="learn.microsoft.com" href="https://learn.microsoft.com/en-us/rest/api/power-bi/admin/workspace-info-get-scan-result" target="_blank" rel="noopener"&gt;GetScanResult API&lt;/A&gt;, and have implemented this in a PySpark Notebook inside of Azure Synapse.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to this page, there should be a dictionary with the key "Roles", but in my response of the API there is no such field. This is what I am looking for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Goal output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;          ......
          "roles": [
            {
              "name": "Teams",
              "modelPermission": "Read",
              "members": [
                {
                  "memberName": "john@contoso.com",
                  "memberId": "ee96296b-fb71-4f65-a8af-c0ec5a7daced",
                  "memberType": "User",
                  "identityProvider": "AzureAD"
                },
                {
                  "memberName": "group@contoso.com",
                  "memberId": "0a1cdbc3-f82c-4001-8b96-be04ae9d25a3",
                  "memberType": "Group",
                  "identityProvider": "AzureAD"
                }
              ],
              "tablePermissions": [
                {
                  "name": "DW_Revenues DW_RevenuesTest",
                  "filterExpression": "[InTeams] = \"True\""
                }
              ]
            }
          ],
          ......&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this is the entire response I get (when I select one of the datasets that the API call):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
    {
       "id":"--------------",
       "name":"--------------",
       "tables":[
          
       ],
       "configuredBy":"--------------",
       "configuredById":"--------------",
       "isEffectiveIdentityRequired":true,
       "isEffectiveIdentityRolesRequired":true,
       "refreshSchedule":{
          "days":[
             "Sunday",
             "Monday",
             "Tuesday",
             "Wednesday",
             "Thursday",
             "Friday",
             "Saturday"
          ],
          "times":[
             "01:00",
             "08:00",
             "09:00",
             "10:00",
             "11:00",
             "13:00",
             "14:00",
             "15:00",
             "16:00",
             "17:00"
          ],
          "enabled":true,
          "localTimeZoneId":"Romance Standard Time",
          "notifyOption":"NoNotification"
       },
       "targetStorageMode":"PremiumFiles",
       "createdDate":"2022-12-08T12:22:43.013",
       "contentProviderType":"PbixInImportMode"
    }
 ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As can be seen, the "&lt;STRONG&gt;Tables&lt;/STRONG&gt;" dictionary only contains an empty list (which is different from the example output of GetScanResult), but also the "&lt;STRONG&gt;Roles&lt;/STRONG&gt;" field is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Things I have tried:&lt;/P&gt;&lt;P&gt;1. Checked the tenant settings to ensure metadata scanning has been enabled (&lt;A title="learn.microsoft.com" href="https://learn.microsoft.com/en-us/fabric/admin/metadata-scanning-setup?source=recommendations" target="_blank" rel="noopener"&gt;info&lt;/A&gt;), I was hoping the settings were turned off and causing this issue, but they were turned on&lt;/P&gt;&lt;P&gt;2. Specified parameters in the&lt;STRONG&gt; getInfo Post API call:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def initiate_scan(aad_token, workspaces):
    url = 'https://api.powerbi.com/v1.0/myorg/admin/workspaces/getInfo'
    headers = {
        'Authorization': f'Bearer {aad_token}',
        'Content-Type': 'application/json'
    }
    body = {
        "workspaces": workspaces,
        "datasetExpressions": True,
        "datasetSchema": True,
        "datasourceDetails": True,
         "getArtifactUsers": True,
        "lineage": True
    }
    
    response = requests.post(url, headers=headers, json=body)
    
    if response.status_code == 202:
        scan_id = response.json().get('id')
        print(f'Scan initiated successfully. Scan ID: {scan_id}, workspaceIDs = {body["workspaces"]} ')
        return scan_id
    else:
        print(f'Failed to initiate scan: {response.status_code}, {response.text}')
        return None&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;3. Tried a &lt;A title="learn.microsoft.com" href="https://learn.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasets-as-admin" target="_blank" rel="noopener"&gt;different API Call&lt;/A&gt; looking something like this: &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A title="api.powerbi.com" href="https://api.powerbi.com/v1.0/myorg/admin/datasets/{dataset_id}," target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://api.powerbi.com/v1.0/myorg/admin/datasets/{&lt;/SPAN&gt;&lt;SPAN&gt;dataset_id&lt;/SPAN&gt;&lt;SPAN&gt;},&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;this results in:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;Failed to get dataset info: 404, {"error":{"code":"ItemNotFound","message":"Dataset abcde-12345-12345-abcde is not found."}}.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Additional Information&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I am using an AAD token which I obtain in the following way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def get_AAD_token(tenant_id, client_id, client_secret, resource):
    token_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/token"
    data = {
        'grant_type': 'client_credentials',
        'client_id': client_id,
        'client_secret': client_secret,
        'resource': resource
    }
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}

    response = requests.post(token_url, data=data, headers=headers)

    if response.status_code == 200:
        json_response = response.json()
        aad_token = json_response['access_token']
        print('Bearer token was obtained successfully')
        return aad_token
    else:
        print(f'Failed to obtain bearer token: {response.status_code}, {response.text}')
        return None&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I am a noob when it comes to Permissions and rights granted via Azure Synapse and this universe in general&lt;/P&gt;&lt;P&gt;3. I think it has something to do with rights, since in the example output there is info about tables and roles&lt;/P&gt;&lt;P&gt;4. I have checked &lt;A title="community.fabric.microsoft.com" href="https://community.fabric.microsoft.com/t5/Developer/Power-BI-Scanner-API-RLS-Information/m-p/3679673" target="_blank" rel="noopener"&gt;this page&lt;/A&gt;&lt;/P&gt;&lt;P&gt;4.1 I have checked &lt;A href="https://learn.microsoft.com/en-us/fabric/admin/metadata-scanning-enable-read-only-apis" target="_self"&gt;this page&lt;/A&gt;&lt;/P&gt;&lt;P&gt;5. I have read to wait a bit between starting the scan and reading the scan, I check for the status to be "Succeeded" before getting the results.&lt;/P&gt;&lt;P&gt;6. I Have ensured roles have been set for the dataset I am checking&lt;/P&gt;&lt;P&gt;7. In short, this is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def initiate_scan(aad_token, workspaces):
    url = 'https://api.powerbi.com/v1.0/myorg/admin/workspaces/getInfo'
    headers = {
        'Authorization': f'Bearer {aad_token}',
        'Content-Type': 'application/json'
    }
    body = {
        "workspaces": workspaces,
        "datasetExpressions": True,
        "datasetSchema": True,
        "datasourceDetails": True,
         "getArtifactUsers": True,
        "lineage": True
    }
    
    response = requests.post(url, headers=headers, json=body)
    
    if response.status_code == 202:
        scan_id = response.json().get('id')
        print(f'Scan initiated successfully. Scan ID: {scan_id}, workspaceIDs = {body["workspaces"]} ')
        return scan_id
    else:
        print(f'Failed to initiate scan: {response.status_code}, {response.text}')
        return None


def check_scan_status(aad_token, scan_id):
    url = f'https://api.powerbi.com/v1.0/myorg/admin/workspaces/scanStatus/{scan_id}'
    headers = {
        'Authorization': f'Bearer {aad_token}',
        'Content-Type': 'application/json'
    }
    
    response = requests.get(url, headers=headers)
    
    if response.status_code == 200:
        status_info = response.json()
        status = status_info.get('status')
        print(f'Scan status: {status}')
        return status, status_info
    else:
        print(f'Failed to check scan status: {response.status_code}, {response.text}')
        return None, None


def get_scan_result(aad_token, scan_id):
    print(f"collecting results for scan {scan_id}")
    url = f'https://api.powerbi.com/v1.0/myorg/admin/workspaces/scanResult/{scan_id}'
    headers = {
        'Authorization': f'Bearer {aad_token}',
        'Content-Type': 'application/json'
    }
    
    response = requests.get(url, headers=headers)
    
    if response.status_code == 200:
        scan_result = response.json()
        print('Scan result retrieved successfully')
        return scan_result
    elif response.status_code == 404:
        print(f'Scan result not found. The scan may have expired or the ID is invalid: {response.text}')
        return None
    else:
        print(f'Failed to get scan result: {response.status_code}, {response.text}')
        return None &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 11:21:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Empty-quot-Roles-quot-column-ib-GetScanResult-API-Call-when/m-p/4013003#M53749</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-27T11:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Empty "Roles" column ib  GetScanResult API Call when trying to find AD Groups in RLS P</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Empty-quot-Roles-quot-column-ib-GetScanResult-API-Call-when/m-p/4015087#M53774</link>
      <description>&lt;P&gt;Hi&amp;nbsp; @Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your use of this Power BI admin API you will also encounter the specific 404 error status code "404, {"error":{"code": "ItemNotFound", "message": "Dataset abcde-12345-12345-abcde is not found."}}." At your convenience, can you verify that the account you generated and used the AAD token for has access to the dataset ID "abcde-12345-12345-abcde"? You can also consider using service principal authentication to execute this API, provided that you also meet the prerequisites of the API for service principals in the documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasets-as-admin" target="_blank"&gt;Admin - Datasets GetDatasetsAsAdmin - REST API (Power BI Power BI REST APIs) | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vyangliumsft_0-1719562843287.jpeg" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1123754i4114188E5AF1B4EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="vyangliumsft_0-1719562843287.jpeg" alt="vyangliumsft_0-1719562843287.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2024 08:20:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Empty-quot-Roles-quot-column-ib-GetScanResult-API-Call-when/m-p/4015087#M53774</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-28T08:20:55Z</dc:date>
    </item>
  </channel>
</rss>

