Many Power Query function not only return their values as advertised in their function documentation, but on top of that a metadata record. This record is like tag that holds additional information about the returned main value (for more details about this, please check out my friend Lars Schreiber’s article about it).
Useful metadata for the Web.Contents function
Today I discovered that the function Web.Contents delivers a really nice record with a couple of useful information. To retrieve header fields, you have to use the Value.Metadata function, like so for example:
This might help for some advanced web query tasks.
How to use
If you want to use this in production, you’d probably branch out the logic. So first use Web.Contents and keep that result in a column or variable. Then add another column that references it and return the metadata record.
Apply the logic check on it and create a last column where you finally parse the content from the binary that Web.Content has returned.
Enjoy & stay queryious đ
The response’s headers, except for Content-Type, are intentionally stripped out unless Web.Contents is invoked within a custom data connector. If you’re not getting the headers you expect from an API endpoint (like an access token), that may be why.
Is there any way to access these stripped response headers in Power Query?
The only way to get all headers (as opposed to a subset) is to use a custom connector.
Upvote suggestion to get all headers back here: https://ideas.fabric.microsoft.com/ideas/idea/?ideaid=e47d7520-1509-ed11-b5cf-281878de6c19