Forum Discussion

Matthew_Kursar's avatar
Matthew_Kursar
Frequent Visitor
1 year ago
Solved

REST API PostWorkspaceInfo Relationships

27/06 Update: Added more specific details to question

 

Hello! I was wondering if there is any way to get the Dataset relationships via the REST API? On the ScanResult API page, it seems like there was intended to be a field for dataset relationships https://learn.microsoft.com/en-us/rest/api/power-bi/admin/workspace-info-get-scan-result 

Associated snippet:

"datasets": [
        {
          "id": "e7e8a355-e77b-4418-a7b8-ae5972fdaa03",
          "name": "ExportB",
          "tables": [
            {...}
          ],
          "relationships": [], # this field here
...insert rest of response

But from my own testing (and scouring some forum posts) it doesn't seem like relationship information is actually available via this API. 

 

I'm using calling PostWorkspaceInfo with the following parameters:

https://api.powerbi.com/v1.0/myorg/admin/workspaces/getInfo?lineage=True&datasourceDetails=True&datasetSchema=True&datasetExpressions=True&getArtifactUsers=True

And in my response there is no 'relationships' key (just completely missing, not returning nothing), but the rest of the data is there. 

 

If I'm mistaken, please let me know as I'm looking for a way to retrieve the relationship info of a dataset/report via an API call. I'm not sure how it's handled on the Microsoft side, but if it could just dump the info in a similar manner to how it's stored in the relationships.tmdl file of a PowerBI Project File report that would allow me (and many others I'm sure) to achieve my lofty goals of scanning reports and ensuring we're following best practice standards (like avoiding bad many-many relationships) across my org.

  • v-dineshya's avatar
    v-dineshya
    1 year ago

    Hi Matthew_Kursar ,

     

    1. The API supports several metadata flags including datasetSchema, datasetExpressions, lineage, and datasourceDetails.It does not explicitly guarantee that the relationships field will be populated even when you set datasetSchema=True .

     

    2. The sample response in the documentation includes a relationships key, but this appears to be illustrative rather than guaranteed output. That metadata scanning must be fully enabled for schema and expression data to be returned.

     

    Note: The relationships field is not reliably returned by the PostWorkspaceInfo API, even with all metadata flags enabled.

     

    You may need to extract relationship data manually from .pbip project files or use XMLA endpoints with tools like SSMS or PowerShell for deeper model, especially if you are looking for  governance and performance validation.

     

    Please refer Microsoft official document.

    Admin - WorkspaceInfo PostWorkspaceInfo - REST API (Power BI Power BI REST APIs) | Microsoft Learn

     

     

    If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

    Thank you

     

8 Replies

  • v-dineshya's avatar
    v-dineshya
    Community Support

    Hi Matthew_Kursar ,

    Thank you for reaching out to the Microsoft Community Forum.

    Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
    Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
    Please show the expected outcome based on the sample data you provided.


    Regards,
    Dinesh

    • Matthew_Kursar's avatar
      Matthew_Kursar
      Frequent Visitor

      I've updated the original question with more details 🙂

       

      What I'm hoping to get from the API call is a response that includes the 'relationships' key similar to this example from the REST API GetScanResult documentation 

      "datasets": [
              {
                "id": "e7e8a355-e77b-4418-a7b8-ae5972fdaa03",
                "name": "ExportB",
                "tables": [
                  {...}
                ],
                "relationships": [], # this field here
      ...insert rest of response

      However, my API responses have most of the data, just not this relationships key

      • v-dineshya's avatar
        v-dineshya
        Community Support

        Hi Matthew_Kursar ,

         

        1. The API supports several metadata flags including datasetSchema, datasetExpressions, lineage, and datasourceDetails.It does not explicitly guarantee that the relationships field will be populated even when you set datasetSchema=True .

         

        2. The sample response in the documentation includes a relationships key, but this appears to be illustrative rather than guaranteed output. That metadata scanning must be fully enabled for schema and expression data to be returned.

         

        Note: The relationships field is not reliably returned by the PostWorkspaceInfo API, even with all metadata flags enabled.

         

        You may need to extract relationship data manually from .pbip project files or use XMLA endpoints with tools like SSMS or PowerShell for deeper model, especially if you are looking for  governance and performance validation.

         

        Please refer Microsoft official document.

        Admin - WorkspaceInfo PostWorkspaceInfo - REST API (Power BI Power BI REST APIs) | Microsoft Learn

         

         

        If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.

        Thank you

         

  • Deku's avatar
    Deku
    Super User

    For PostWorkspaceInfo do you enhanced metadata enabled?