Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I need help dynamically pulling headers when importing data via API in PowerQuery. I'm currently entering headers manually, which is terribly inefficient and requires manual updates whenever new fields are added to the API.
Here's what I have:
let
endpoint = "(REST API endpoint URL)",
directive= "A",
cache = "false",
command = Record.FromList({keys}) ,
headers = Record.FromList({command},{"Headers"}),
payload = Json.Document(Web.Contents(endpoint, headers)),
value = payload[value],
#"Converted to Table" = Table.FromList(value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {
"Header 1",
"Header 2",
"Header 3"
})
in
#"Expanded Column1"
In this query's current state, only the identified headers ("Header 1", "Header 2", "Header 3") are pulled into the table.
What I'd rather say is, "Give me every column from all headers available." That way, when I refresh the dataset, any new columns will be pulled dynamically.
Any help would be appreciated. Thanks!
Solved! Go to Solution.
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", Headers)
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", Headers)
It worked. Thanks so much!
I have a question. How did you define key?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.