Skip to content

Instantly share code, notes, and snippets.

@katoen
Created May 25, 2020 22:07
Show Gist options
  • Save katoen/15954a90efe98ec4b608ff1a1e7258d6 to your computer and use it in GitHub Desktop.
Save katoen/15954a90efe98ec4b608ff1a1e7258d6 to your computer and use it in GitHub Desktop.
REST API Power BI in Power Query - List tables
/*
docs.microsoft.com/en-us/rest/api/power-bi/pushdatasets/datasets_gettables
Easy auth token:
https://datagulp.com/powerbi/power-bi-rest-api-how-to-get-authentication-token-with-powershell-cmdlets/
*/
let
  Source = Json.Document(
    Web.Contents(
      "https://api.powerbi.com/v1.0/myorg/datasets/"& DATASETID &"/tables"
      [Headers = [#"Content-Type" = "application/json"accept = "application/json"Authorization
        = "Bearer " & PBIKEY]]
    )
  ),
  value = Source[value],
  #"Converted to Table" = Table.FromList(
    value
    Splitter.SplitByNothing(), 
    null
    null
    ExtraValues.Error
  ),
  #"Expanded Column1" = Table.ExpandRecordColumn(
    #"Converted to Table"
    "Column1"
    {"name"}, 
    {"name"}
  )
in
  #"Expanded Column1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment