cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dkpcr5
Frequent Visitor

Dynamic table headers from API

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!

1 ACCEPTED SOLUTION
lbendlin
Super User III
Super User III

#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", Headers)

View solution in original post

2 REPLIES 2
lbendlin
Super User III
Super User III

#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", Headers)

View solution in original post

dkpcr5
Frequent Visitor

It worked. Thanks so much!

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Kudoed Authors