New Web.Headers M function
This content applies to: Power Query online Power Query desktop
You may have noticed a new M function was added to Power Query recently: Web.Headers. This function allows you to make HEAD requests to web services – the existing Web.Contents function, which it resembles closely, only allows you to make GET and POST requests. You can use the Web.Headers function to return the HTTP headers that would be returned if the URL passed to it was instead used to make a GET request.
For example, the following M query returns a record with the HTTP headers returned by a HEAD request to the URL”https://bing.com/search?q=Power+Query” :
let searchText = "Power Query", output = Web.Headers( "https://www.bing.com", [ RelativePath = "search", Query = [q = searchText] ] ) in output
The metadata of the record returned contains the HTTP response status code for the request. For example:
let searchText = "Power Query", output = Web.Headers( "https://www.bing.com", [ RelativePath = "search", Query = [q = searchText] ] ) in Value.Metadata(output)
…returns a record with a record containing the field Response.Status: