cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dkpcr5
New Member

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 REPLY 1
lbendlin
Super User III
Super User III

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

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors